Wednesday, March 15, 2006

st: RE: RE: macro expansion

I guess you are not telling us everything.

For example, if some of your code is executed from the Command window and some from the do-file editor, then the "program" (by courtesy) in the editor cannot see the locals defined from the Command window.

Remember: -local- means precisely that. Local macros are only visible within the same program, meaning a -program- defined as such, a do-file, code in the do-file editor or the main session running from the Command window.

Nick n.j.cox@durham.ac.uk (not a Professor!)

Sean Shu > I have following code which let two local macros expand in a > file path. > But after running the looping, the files are saved under C: directly, > instead of the directory suggested by the code. > > local path = "C:/EPI Projects/RRFSS Trends/" > local fname = "Smoking Vehicle\vehicle0" > cd "C:\EPI Projects\RRFSS Trends\data" > forval i = 1/4 { > insheet cat prop ucl lcl popsize using raw0`i'.txt, clear > generate year = 200`i' > save "`path'/`fname'`i'", replace > } > > Messages from STATA after running the above code > forval i = 1/4 { > 2. insheet cat prop ucl lcl popsize using raw0`i'.txt, > clear > 3. generate year = 200`i' > 4. *save "C:\EPI Projects/RRFSS, replace > . save "`path'/`fname'`i'", replace > 5. } > > (5 vars, 2 obs) > file /1.dta saved > (5 vars, 2 obs) > file /2.dta saved > (5 vars, 2 obs) > file /3.dta saved > (5 vars, 2 obs) > file /4.dta saved >

* * 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/


Tag:


Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?