I am using the egen rowlast command to tell me the depression scores for patients in the last wave that they have data, please see the dataex code below showing the scores in the last wave and the rowlast output:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(DEPsymptoms_w9 DEPsymptomslastwaves) 1 1 . 0 . 0 1 1 0 0 4 4 end
As you can see from the 2nd and 5th lines, due to egen treating missing values as 0, I cannot differentiate in the rowlast output when a score is 0 if this is a genuine score of 0 or a missing value.
I have attempted the below codes to set the missing to . but none have worked:
keep if !missing(DEPsymptomslastwaves)
recode DEPsymptomslastwaves (missing=.)
keep if DEPsymptomslastwaves !=.
For reference, this is code I used for the egen command:
egen DEPsymptomslastwaves=rowlast(DEPsymptoms_w1 DEPsymptoms_w2 DEPsymptoms_w3 DEPsymptoms_w4 DEPsymptoms_w5 DEPsymptoms_w6 DEPsymptoms_w7 DEPsymptoms_w8 DEPsymptoms_w9)
Is anyone able to help in how to override the egen setting of not treating missing values as 0 please?
Many thanks in advance,
Rhian
0 Response to How to use the egen command and not set missing to zero
Post a Comment