Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: putting string variable values into macros


From   "reardon, sean f." <[email protected]>
To   <[email protected]>
Subject   st: putting string variable values into macros
Date   Mon, 18 Jul 2005 12:21:15 -0700

friends --

i want to create a series of local macros that contain the values of a
string variable:  something like this:

gen obs=_n
forv n=1/20 {
	local mac`n' "value of string variable x if obs==`n'"
}

the idea is i would end up with 20 macros (mac1 mac2, mac3, ..., mac20),
each of which would contain the corresponding value of a string variable
x.

i can do this if x is a numeric variable like this:

gen obs=_n
forv n=1/20 {
	qui su x if obs==`n', meanonly
	local mac`n' = r(mean)
}

but i can't think of how to do it x is a string variable. i'm sure
there's something obvious, but i'm stuck.

suggestions?

thanks,
sean.


_____________________________
 
please note new contact information:
_____________________________
 
sean f. reardon
associate professor of education and (by courtesy) sociology
school of education
485 lasuen mall, #315
stanford university
stanford, ca 94305-3096
650.736.8517 (office phone)
650.725.7412 (office fax)
[email protected]
_____________________________
 



*
*   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