Hi,
My dataset has 25 variables for diagnoses (dx1 to dx25). I use the following code to identify patients with particular conditions. Is there are way for me to shorten this code so that I do not have to specify a line for each diagnosis variable.
I am using Stata 12 for Windows.
Thank you,
Caroline
My dataset has 25 variables for diagnoses (dx1 to dx25). I use the following code to identify patients with particular conditions. Is there are way for me to shorten this code so that I do not have to specify a line for each diagnosis variable.
Code:
forvalues i=2009/2012 { use "/scratch/abc/XYZ/xyz_`i'_core.dta", clear keep if inlist(dx1, "75611", "75612") | /// inlist(dx2, "75611", "75612") | /// inlist(dx3, "75611", "75612") | /// inlist(dx4, "75611", "75612") | /// inlist(dx5, "75611", "75612") | /// inlist(dx6, "75611", "75612") | /// inlist(dx7, "75611", "75612") | /// inlist(dx8, "75611", "75612") | /// inlist(dx9, "75611", "75612") | /// inlist(dx10, "75611", "75612") | /// inlist(dx11, "75611", "75612") | /// inlist(dx12, "75611", "75612") | /// inlist(dx13, "75611", "75612") | /// inlist(dx14, "75611", "75612") | /// inlist(dx15, "75611", "75612") | /// inlist(dx16, "75611", "75612") | /// inlist(dx17, "75611", "75612") | /// inlist(dx18, "75611", "75612") | /// inlist(dx19, "75611", "75612") | /// inlist(dx20, "75611", "75612") | /// inlist(dx21, "75611", "75612") | /// inlist(dx22, "75611", "75612") | /// inlist(dx23, "75611", "75612") | /// inlist(dx24, "75611", "75612") | /// inlist(dx25, "75611", "75612") save "/scratch/abc/XYZ_`i'_pqr.dta", replace }
Thank you,
Caroline
Comment