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
Multivariate fractional probit and heckman selectionDear all, I am attempting a "Heckman type" of analysis that combines both the Multivariate Fraction…
How to generate cumulative sum of changes of a variable in a group across timeDear All, I'm new on Statalist and I'm still figuring out how to use dataex so apologies for my dat…
net problems (can't find stata.toc)Can anyone shed any light on the following. In the first command I specify the HTTP directory and t…
Summing over a range of observationsHi, I'm doing a long-run event study using the methodology of Kolari & Pynnonen (2018), where i …
In need of help with a dataset containing multiple observations by IDDear Statalist, Hello! I've been a regular visitor here for months, but this is my first time posti…
Subscribe to:
Post Comments (Atom)
0 Response to Making the observations of a string variable as variable names after drop_all
Post a Comment