Hello,
I am trying to generate variables using a local macro. I am using household data in which each observation has an occupation ID. There are 298 different occupation IDs. I have reduced these to the 50 most common using the following code:
To develop a dummy for each of the top 50 occupations, I have done the following:
Next, I want to generate a dummy for each occupation ID that interacts with a dummy variable for labor force participation. I have a dummy laborforce that takes a value of 1 if an observation is in the labor force. The following code results in an error for invalid syntax:
I am not sure why this syntax is invalid. I thought that I had correctly defined every macro in this line of code. Perhaps I did this incorrectly. Thank you.
I am trying to generate variables using a local macro. I am using household data in which each observation has an occupation ID. There are 298 different occupation IDs. I have reduced these to the 50 most common using the following code:
Code:
keep if _n<=50 levelsof occ1950, local(top_occs)
Code:
foreach occid of local top_occs { gen occ`occid'=(occ1950==`occid') }
Code:
gen labf`occid'=(occ1950==`top_occs')*(labforce==1)
Comment