Hello Everyone,
My first post
Looking for help in getting this code to run. error is invalid numlist
I'm very new to STATA and this is the task I'm faced with:
I'm creating a dummy variable that indicates a certain type of case,
then I need foreach to loop through checking for adjacent cases.
I would like to do this for multiple ranges 1,2,3,4,5,6,7,8,9,10 cases away creating a new dummy variable,
then tab with Fisher's exact Phi.
Later I will need to add breaks for another area group variable value so that the loop stops after finishing an area and then begins again in a new area value.
Here is what I have
sort seqid
gen cd1 = 0
replace cd1 = 1 if (icd1==1)|(icd1==5)|(icd1==9)|(icd1==28)|(icd1==64 )|(icd1==79)|(icd1==92)|(icd1==104)|(icd1==154)|(i cd1==189)
gen cda = 0
foreach j of numlist = (1/10){
foreach i of numlist = (1/`j')
{
if (cd1[_n-`i'] | cd1[_n+1]) replace cda = 1
}
tab cd1 cda exact
}
I really appreciate any help!
My first post

Looking for help in getting this code to run. error is invalid numlist
I'm very new to STATA and this is the task I'm faced with:
I'm creating a dummy variable that indicates a certain type of case,
then I need foreach to loop through checking for adjacent cases.
I would like to do this for multiple ranges 1,2,3,4,5,6,7,8,9,10 cases away creating a new dummy variable,
then tab with Fisher's exact Phi.
Later I will need to add breaks for another area group variable value so that the loop stops after finishing an area and then begins again in a new area value.
Here is what I have
sort seqid
gen cd1 = 0
replace cd1 = 1 if (icd1==1)|(icd1==5)|(icd1==9)|(icd1==28)|(icd1==64 )|(icd1==79)|(icd1==92)|(icd1==104)|(icd1==154)|(i cd1==189)
gen cda = 0
foreach j of numlist = (1/10){
foreach i of numlist = (1/`j')
{
if (cd1[_n-`i'] | cd1[_n+1]) replace cda = 1
}
tab cd1 cda exact
}
I really appreciate any help!
Comment