SOS!
I have a panel data containing household information that was collected mainly in the baseline year. When collecting data, if there were no changes in a period compared to the previous period, the variables are coded 0. Now I want to recode the household head's occupation (HHocc) from 0 to the value of the past period for each household id.
I was doing it manually but there are about 4000 observations to change so I need a quicker way. Do you have an idea how to do it?
The following is how data look like:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(qdate HHocc id) 230 0 47 231 0 47 232 1 47 233 1 47 234 1 47 235 1 47 219 1 48 220 7 48 221 0 48 222 0 48 223 0 48 224 0 48 225 0 48 226 0 48 227 0 48 228 0 48 229 0 48 230 0 48 231 0 48 232 1 48 233 1 48 end format %tq qdate label values id id label def id 47 "a049", modify label def id 48 "a050", modify
I tried to apply this code but it did not work:
Code:
recode HHocc (0=1) if (qd==219 & HHocc==1)
0 Response to Recode a variable to the same previous value by category
Post a Comment