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

st: RE: putting string variable values into macros


From   "Jann, Ben" <[email protected]>
To   <[email protected]>
Subject   st: RE: putting string variable values into macros
Date   Mon, 18 Jul 2005 21:30:41 +0200

Try

 forv n=1/20 {
	local mac`n' = x[`n']
 }

ben

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of 
> reardon, sean f.
> Sent: Monday, July 18, 2005 9:21 PM
> To: [email protected]
> Subject: st: putting string variable values into macros
> 
> 
> 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/
> 

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