Hi,
I have a datasheet that has a string variable named "person" with observations like "AM", "MF", "KR", "PM", "RR", etc.
what I want to do is to sum a list of all unique observations of this variable, then drop everything, then in a new spreadsheet generate new variables with the name of these observations like "AM", "MF", "KR", etc.
What I did was (in short form):
levelsof person
drop _all
foreach x in `r(levels)' {
gen `x' = .
}
But this does not work and I guess it is because it cannot read from a string list.
Do you have any idea how I can come over this? and how can I make variables from a list of single observations from an already dropped string variable?
Thank you
Related Posts with Making the observations of a string variable as variable names after drop_all
How to create a formlacode year var2 top5 1100 201712 5 1 1100 201712 5 2 1100 201712 5 3 1100 201712 4.9 4 1100 201712 4.…
marginscontplot problem.Dear All, I have a dataset with two variables (simplified). The basic statistics Code: . sum indep…
Can you combine data vertically?I am looking at data on methods of recycling for towns in the UK for five years, however my data on …
Clean syntax in STATAhi, please help me! I found command that is not recognized in STATA14 but is used in Chaney2012 pape…
Estimating Productivity adnI am trying to find impact of (Dividends) on (Firm Sales) controlling for the firm characteristics i…
Subscribe to:
Post Comments (Atom)
0 Response to Making the observations of a string variable as variable names after drop_all
Post a Comment