Statalist


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

Re: st: getting a list into a macro


From   David Kantor <[email protected]>
To   [email protected]
Subject   Re: st: getting a list into a macro
Date   Fri, 26 Sep 2008 15:45:28 -0400

At 03:28 PM 9/26/2008, Rich wrote:
I have a string variable that is 6 characters long -- about 100 observations

I want to get each value into one long macro with spaces between each value -- how can I do that?

Thanks,
If I understand correctly, you want one macro, with all the values.

forvalues j = 1/`=_N' {
local m "`m' `=myvar[`j']'"
}

This puts an extra space at the beginning. There are ways to avoid it if that's a problem -- such as:

forvalues j = 1/`=_N' {
local m "`m'`sp'`=myvar[`j']'"
if `j' ==1 {
local sp " "
}
}

HTH
--David

*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* 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