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 with Stata Programming


From   Michael Stewart <[email protected]>
To   statalist <[email protected]>
Subject   st: Need Help with Stata Programming
Date   Tue, 4 Jun 2013 22:02:38 -0400

Dear Statalist user ,

I need help with stat porgramming.

I am working with multiple datasets and with the  help of statalist
users, was able to figure out a way to use multiple datasets, complete
 data management tasks and save them under separate files

MY DATA STRUCTURE:
***************************************************************
auto-1 contains variables DX1-DX15;  variables DXCCS1-DXCCS-15 + other variables
auto-2 contains variables DX1-DX25 ;  variables DXCCS1-DXCCS-25  +
other variables
auto-3 contains variables DX1-DX35 ;  variables DXCCS1-DXCCS-35  +
other variables
****************************************************************


My current code is as follows
***********************************************
local ds1 "D:\_Dummy\multiple\1\auto_1.dta"
local ds2 "D:\_Dummy\multiple\2\auto_2.dta"
local ds3 "D:\_Dummy\multiple\3\auto_3.dta"
local all ds1 ds2 ds3
foreach x in `all'{
use ``x'',clear
gen x=0 if mpg>25
gen y=2 if headroom<5
save ``x''_new.dta,replace
}
***********************************************

New Problem:1:
The files are being saved under the same folder  as the auto-1,auto-2
files.If I need to store the foled with path C:\research\auto; how can
I accomplish it (I do not know as the filepath seems to be fixed in
the ``x'' macro )

NEW PROBLEM-2:
I need to append file-1 to auto-1 after approproate datamanagement in
the  loop; append file-2 to auto-2 after approproate datamanagement in
the  loop; append file-3 to auto-3 after approproate datamanagement in
the  loop. How can I do it

New Problem-3:
I need to merge  file-A to auto-1 after approproate datamanagement in
the  loop; merge  file-B to auto-2 after approproate datamanagement in
the  loop; merge  file-B to auto-3 after approproate datamanagement in
the  loop. How can I do it

Please help me

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