Hello,
I have a dataset that is similar to the following:
clear
input str6 id byte(ja18aqol1 ja18aqol2 ja18aqol3 ja18aqol4 ja18aqol5 ja18aqol6 ja18aqol7 ja18aqol8 ja18aqol9 ja18aqol10 ja18aqol11 ja18aqol12)
"Alex" 1 1 1 1 . . 1 1 . 1 1 1
"Jack" 1 1 1 1 1 1 1 1 1 1 1 1
"Sam" . . . . . . . . . . . .
end
[/CODE]
I also have the following code (part of it):
g Q1 = aqol1
g Q2 = aqol2
g Q3 = aqol3
g Q4 = aqol4
g Q5 = aqol5
g Q6 = aqol6
g Q7 = aqol7
g Q8 = aqol8
g Q9 = aqol9
g Q10 = aqol10
g Q11 = aqol11
g Q12 = aqol12
************************************************** ***************
********* Imputing Missing Values in Database *********
************************************************** **************
* Dimension 1. Independent Living
egen IL_miss = rowmean(Q1 Q2 Q3)
egen ILmissno = rowmiss(Q1 Q2 Q3)
replace Q1=round(IL_miss) if missing(Q1) & ILmissno==1
replace Q2=round(IL_miss) if missing(Q2) & ILmissno==1
replace Q3=round(IL_miss) if missing(Q3) & ILmissno==1
-----------------------------------------------------------------------------
As you can see the code above starts with 'g Q1 = aqol1', but in my dataset I have ja18 as a prefix since I have a repeated measures dataset. The aqol survey questions are also repeated for april (ap18), july (ju18), october (oc18), january 2019 (ja19), and april 2019 (ap19).
For each month, If I were to follow the code through until the end, I will end up with a single numeric score (e.g. I would have a score for january 2018, april 2018, july 2018, etc.). Is there a way to modify the code using loops/macros that will generate a score for each month?
I have a dataset that is similar to the following:
clear
input str6 id byte(ja18aqol1 ja18aqol2 ja18aqol3 ja18aqol4 ja18aqol5 ja18aqol6 ja18aqol7 ja18aqol8 ja18aqol9 ja18aqol10 ja18aqol11 ja18aqol12)
"Alex" 1 1 1 1 . . 1 1 . 1 1 1
"Jack" 1 1 1 1 1 1 1 1 1 1 1 1
"Sam" . . . . . . . . . . . .
end
[/CODE]
I also have the following code (part of it):
g Q1 = aqol1
g Q2 = aqol2
g Q3 = aqol3
g Q4 = aqol4
g Q5 = aqol5
g Q6 = aqol6
g Q7 = aqol7
g Q8 = aqol8
g Q9 = aqol9
g Q10 = aqol10
g Q11 = aqol11
g Q12 = aqol12
************************************************** ***************
********* Imputing Missing Values in Database *********
************************************************** **************
* Dimension 1. Independent Living
egen IL_miss = rowmean(Q1 Q2 Q3)
egen ILmissno = rowmiss(Q1 Q2 Q3)
replace Q1=round(IL_miss) if missing(Q1) & ILmissno==1
replace Q2=round(IL_miss) if missing(Q2) & ILmissno==1
replace Q3=round(IL_miss) if missing(Q3) & ILmissno==1
-----------------------------------------------------------------------------
As you can see the code above starts with 'g Q1 = aqol1', but in my dataset I have ja18 as a prefix since I have a repeated measures dataset. The aqol survey questions are also repeated for april (ap18), july (ju18), october (oc18), january 2019 (ja19), and april 2019 (ap19).
For each month, If I were to follow the code through until the end, I will end up with a single numeric score (e.g. I would have a score for january 2018, april 2018, july 2018, etc.). Is there a way to modify the code using loops/macros that will generate a score for each month?
Comment