Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

st: Need help using global macros


From   Michael Stewart <[email protected]>
To   statalist <[email protected]>
Subject   st: Need help using global macros
Date   Sun, 17 Nov 2013 08:37:46 -0500

Hi ,

I am trying to use global macro, set up an output folder to save files
after data management .

However,after data management,  I am not able to store the files as
names similar to their original names.

My code is as follows.

************Code Start**********************
clear
macro drop _all
global output "Y\Data"
local x "Z\Data\file_summer_1"
local y "Z\Data2\file_winter_1"
local all  x y
foreach z in `all'{
use ``z'',clear
data management step
.
data management step

save "$output\``z''_new.dta",replace
}
************Code Ends*********************

Problem : I am not able to store the files after data management in
the output folder as "file_summer_1_new" and  "file_winter_1".The
files are being stored as "x_new" and "y_new".

Can you please help .  Thank you very much for your time and effort.


-- 
Thank you ,
Yours Sincerely,
Mike.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index