Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: about macro's double quotes

From   "Martin Weiss" <>
To   <>
Subject   st: RE: about macro's double quotes
Date   Tue, 9 Mar 2010 21:20:15 +0100


If you want to read up on -macro-s, check out manual [U], section 18.3. 

What do you want to achieve with your outer loop? You let it cycle through
three elements of a -global-. The -gen- and -replace- statements inside the
second loop are supposed to be executed only for the first element of the
-global-. Would it not be much easier to drag the -gen-/-replace- statement
out of the inner loop, and ditch the outer one? Maybe this is taken out of
context, but from what is visible in your post, the outer loop is


-----Original Message-----
[] On Behalf Of G. Dai
Sent: Dienstag, 9. März 2010 20:20
Subject: st: about macro's double quotes

dear all,
I'm a first time  user of macros. As you can see from below, I want to
generate a  new var r`i'pnhm when x=md.  After execute the do file, it
runs smoothly for x=md. After that, however, I was always reminded by STATA
               r5pnhm5y already defined
so what's wrong with the following program. BTW,I'm little bit confused by
the macro
quotes, can anyone say tips?

global set "md mom dad";
foreach x in $set {;
forvalues i=5/8{;
gen r`i'pnhm=. if "`x'"=="md";
replace r`i'pnhm=int(10*r`i'pnhm5y)/10 if "`x'"=="md";

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index