Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: re: data manipulation question


From   David Airey <[email protected]>
To   [email protected]
Subject   st: re: data manipulation question
Date   Tue, 26 Jun 2007 16:20:17 -0500

Starting from where you are now,

foreach v of var iso_* {
	local newname "`: var label `v''"
	local newname : subinstr local newname "iso==" ""
	rename `v' `newname'
}

Starting from your original -iso_str-:

levelsof iso_str, local(levels)
foreach l of local levels {
	gen byte `l' = iso_str == "`l'"
}

However, this example really hinges on the fact that
your string values happen all to be legal variable names.

Nick
[email protected]


In trying out solutions just provided I did run into what you said here. I had a string with "." as the content. I had to replace that with "" for the levels of solution to work, which it did! Thank you! I also see that the last time I used levels it was levels rather than the new Stata 9 (probably 10) levelsof.

--
David C. Airey, Ph.D.
Research Assistant Professor

*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index