Statalist The Stata Listserver


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

Re: st: RE: macro expansion


From   Sean Shu <sshu@hkpr.on.ca>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: macro expansion
Date   Wed, 15 Mar 2006 16:08:00 -0500

Hi,
It works the same after I took the trailing slash in my path macro. The back slash in my fname macro works fine in STATA. I guess something else is wrong. Thanks!

Sean

Alex Ogan wrote:

You have a trailing slash in your path macro, but then you manually add
another slash in your save command.

You have a backslash in your fname macro which should be a forward
slash.

It's often helpful to use a display command to check what you are trying
to do in situations like this, i.e.:
display "`path'/`fname'`i'"


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Sean Shu
Sent: Wednesday, March 15, 2006 3:10 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: macro expansion

Hi there,

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

Any one knows what has gone wrong? Thanks so much!

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


This message is intended solely for the designated recipient(s). It may contain confidential or proprietary information and may be subject to confidentiality protections. If you are not a designated recipient, you may not review, copy, or distribute this message. If you receive this in error, please notify the sender by reply e-mail and delete this message.
Arrowstreet Capital, L.P. is an Equal Opportunity Employer.


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



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