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

Re: st: getting a list into a macro

From   Richard Goldstein <>
Subject   Re: st: getting a list into a macro
Date   Fri, 26 Sep 2008 15:48:55 -0400

Thank you to both Sergiy and to David!

Sergiy Radyakin wrote:
sysuse auto
generate myvar=substr(make,1,6)
forvalues i=1/`=_N' {
  local mylist `"`mylist' `=myvar[`i']'"'  /* do not put equal sign
after local mylist */
display `"`mylist'"'

If you expect spaces among your 6 characters you might want to enclose
`=myvar[`i']' in quotes as well. same if some observations have

Regards, Sergiy Radyakin

On Fri, Sep 26, 2008 at 3:28 PM, Richard Goldstein
<> 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?


*   For searches and help try:

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