Hello,
I've got a dataset with rows specific to an individual and columns specific to certain themes (coded as 0 (no) or 1 (yes) depending on whether the theme was reported). I want to generate a new variable that is a summary of all the themes reported so I can quickly compare how many people reported each theme and also look at variations in the frequencies of themes across specific demographic groups. To create a single variable that captures all the themes reported, I have done the following:
gen all_themes=.
replace all_themes=0 if theme1==1
replace all_themes=1 if theme2==1
replace all_themes=2 if theme3==1
etc
However this fails to capture multiple themes that have been reported by the same person (if they report theme1 and theme3 they would only be recorded as having theme3 based on the (probably very inefficient) method I'm using above).
Any advice would be greatly appreciated.
With many thanks,
Johanna
Related Posts with Creating new variable across rows
Storing estimated coefficients in a loopHello everyone, I am working on a dataset containing daily stock returns of more than 3000 firms a…
Can 'dsge' command be a simpler alternative to 'sspace' for natural interest rate estimation?Hi I’m grad student on Economics but basically I’m an idiot if it comes to econometrics software or …
Is it possible to make the Hausman specification test by comparing two-way error component models?Good morning. I would like to know if the comparison between the two-way effect random effects compo…
IpfrakingI'm using Ipfraking to generate weights for my survey data. For some reason when the iteration fini…
Programming minimum distance estimator using optimizeI'm trying to program up a minimum distance estimator for a structural model that attempts to match …
Subscribe to:
Post Comments (Atom)
0 Response to Creating new variable across rows
Post a Comment