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
GraphHello, any guidance or where to start if I want to build a graph similar to this one? Thanks …
fracregI am using fracreg logit to model a proportion. My data set is a time series. Do I need to test for …
Rounding, multiple decimals off and LocalsI have been trying to get the round function to feed some locals that I use to create graphs labels,…
Problems with spmapGood afternoon, the comment is new with the generation of database in STATA. OBJECTIVE: GENERATE MAP…
count the number of distinct observations across variablesHello Stata folks, I am working on a dataset that each school ID has 7 years of data capturing princ…
Subscribe to:
Post Comments (Atom)
0 Response to Making the observations of a string variable as variable names after drop_all
Post a Comment