Hi all,
I'm trying to set up a dummy variable for whether an individual grows crops or not. However I have 200 variables in the format of YES = 1 and NO = 0 [with a lot of missing values]. Figure 1 shows the data style, I created a varlist for all variables starting with ag4a_06
Then with this I'm trying to create the dummy with this code:
However I get the error "Invalid ag4a_06M1_100" which is only the second ag4a_06 variable?
The variable is broken down as such:
- ag4a_06 refers to the question number [Did you harvest any of [CROP] on this plot?] so is either missing, 1 or 2.
- MX refers to the plot number
- _Y refers to the crop id
Figure 1:
I'm trying to set up a dummy variable for whether an individual grows crops or not. However I have 200 variables in the format of YES = 1 and NO = 0 [with a lot of missing values]. Figure 1 shows the data style, I created a varlist for all variables starting with ag4a_06
Code:
vl create harvested = (ag4a_06*)
Code:
gen harvest = 1 replace harvest = 0 if $harvested = 2
The variable is broken down as such:
- ag4a_06 refers to the question number [Did you harvest any of [CROP] on this plot?] so is either missing, 1 or 2.
- MX refers to the plot number
- _Y refers to the crop id
Figure 1:
Comment