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 Programming multiple datasets
From
Michael Stewart <[email protected]>
To
statalist <[email protected]>
Subject
st: Need help with Programming multiple datasets
Date
Sun, 2 Jun 2013 11:40:15 -0400
Need help with Programming multiple datasets
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
include "D:\_Dummy\multiple\4\a.do"
include "D:\_Dummy\multiple\5\b.do"
save ``x''_new.dta,replace
}
***********************************************
NEW PROBLEM-1:
If I want to run a forvalues loop in local "a" OR local "b" FOR ONLY
DX1-15(for auto_1 ) OR DX1-25(auto_2) OR DX1-35(auto_3) BUT SHOULD NOT
LOOP OVER ANY OTHER SIMILAR VARIABLES like DXCCS1 DXCCS2 etc
How can I modify my present forvalues loop to INCLUDE VARYING NUMBER
OF DX* VARIABLES
My present loop is
forvalues y=2/15{
icd9 generate diag_`x'=DX`x', range("xxx.x")
}
NEW PROBLEM-2:
If I want to run a forvalues loop in local "a" OR local "b" FOR ONLY
DXCCS1-15(for auto_1 ) OR DXCCS1-25(auto_2) OR DXCCS1-35(auto_3) BUT
SHOULD NOT LOOP OVER ANY OTHER SIMILAR VARIABLES like DX1 DX2 etc
How can I modify my present forvalues loop to INCLUDE VARYING NUMBER
OF DX* VARIABLES
My present loop is
forvalues y=2/15{
icd9 generate diag_`x'=DX`x', range("xxx.x")
}
IF FOREACH LOOP is better , please let me know the appropriate code
I thank in advance for all your help.
--
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/