[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

From |
"Martin Wang" <zwang215@gmail.com> |

To |
"statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu> |

Subject |
Re: Re: st: RE: a simple macro problem |

Date |
Sun, 29 Jun 2008 01:30:41 +0800 |

Dear Eva, Thank you for your help! It works well! Many thanks~~ Martin ======= 2008-06-29 00:45:25 Original Message£º======= >Martin, > >Make that > >local dvar=" gov\`j' totalassets" > >and it ought to work. Note the backslash character right in front of >`j'. In Stata, the backslash is an escape character, and prevents the >immediate substitution of the macro. Compare this: > >local j 1 >di " this is macro `j' " >di " this is macro \`j' " > >Eva > >2008/6/28 Martin Wang <zwang215@gmail.com>: >> Hi Martin, >> >> Thank you for your advice! But I still want to use the original code since I have other variations on the code. So could anyone help out? >> >> Many thanks! >> >> Martin >> >> ======= 2008-06-28 02:57:13 Original Message£º======= >> >>>foreach gov in any gov1 gov2{ >>> reg sales `gov' totalassets >>>} >>> >>>Not sure where the mistake is in yours, probably something with the local >>>"dvar" being unable to hold the string you are offering it because the `j' >>>must be evaluated the moment you define "dvar"... >>> >>>Martin Weiss >>>_________________________________________________________________ >>> >>>Diplom-Kaufmann Martin Weiss >>>Mohlstrasse 36 >>>Room 415 >>>72074 Tuebingen >>>Germany >>> >>>Fon: 0049-7071-2978184 >>> >>>Home: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1130 >>> >>>Publications: http://www.wiwi.uni-tuebingen.de/cms/index.php?id=1131 >>> >>>SSRN: http://papers.ssrn.com/sol3/cf_dev/AbsByAuth.cfm?per_id=669945 >>> >>> >>>-----Original Message----- >>>From: owner-statalist@hsphsun2.harvard.edu >>>[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Martin Wang >>>Sent: Friday, June 27, 2008 8:53 PM >>>To: statalist@hsphsun2.harvard.edu >>>Subject: st: a simple macro problem >>> >>>Dear all, >>> >>>I have the following macro, but it doesn't work as I expected: >>>I have gov1, gov2 >>> >>> >>>and I wrote: >>> >>>local dvar=" gov`j' totalassets" >>> local j=1 >>> >>> while `j'<3{ >>> reg sales `dvar' >>> local j = `j' + 1 >>> } >>> >>>I expect this will run sales= gov1 totalassets and sales= gov2 totalassets, >>>but only the first one ran twice, no second one. Anyone could help me out? >>> >>>Many thanks! >>> >>>Martin >>> >>> >>>* >>>* For searches and help try: >>>* http://www.stata.com/support/faqs/res/findit.html >>>* http://www.stata.com/support/statalist/faq >>>* http://www.ats.ucla.edu/stat/stata/ >>> >>>* >>>* For searches and help try: >>>* http://www.stata.com/support/faqs/res/findit.html >>>* http://www.stata.com/support/statalist/faq >>>* http://www.ats.ucla.edu/stat/stata/ >> >> = = = = = = = = = = = = = = = = = = = = >> >> >> >> >> * >> * For searches and help try: >> * http://www.stata.com/support/faqs/res/findit.html >> * http://www.stata.com/support/statalist/faq >> * http://www.ats.ucla.edu/stat/stata/ >> > >* >* For searches and help try: >* http://www.stata.com/support/faqs/res/findit.html >* http://www.stata.com/support/statalist/faq >* http://www.ats.ucla.edu/stat/stata/ = = = = = = = = = = = = = = = = = = = = * * For searches and help try: * http://www.stata.com/support/faqs/res/findit.html * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

- Prev by Date:
**Re: st: RE: a simple macro problem** - Next by Date:
**st: post oaxaca decomposition** - Previous by thread:
**Re: st: RE: a simple macro problem** - Next by thread:
**st: post oaxaca decomposition** - Index(es):

© Copyright 1996–2015 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |