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
Managing time factor in repeated-measures ANOVAHello, I'm analysing data from a protocol which in fact works under the same structure as described …
Error when using medsem command in simultaneous group SEM estimationHi all, I am running a between groups SEM with multiple mediators. In one group there is a signific…
Inserting blank rows at specific observations in datasetI am trying to manipulate a text (.tex) document (a multiple-choice exam) in Stata, which I realize …
How to regress with seasonality dummy variablesExcuse my perhaps dumb question, however I have a dataset consisting of daily crime date and weather…
How to open codebook file (.cdb)?I downloaded a dataset, which includes .cdb file. How to open it? …
Subscribe to:
Post Comments (Atom)
0 Response to Making the observations of a string variable as variable names after drop_all
Post a Comment