Statalist


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

RE: st: RE: simple programming question relating to lists


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: simple programming question relating to lists
Date   Wed, 14 Nov 2007 17:09:24 -0000

You could cut out the middle macro. 

tab y, gen(yf) 
local vars yf1-yf`r(r)'

The downside of that is that it must be done while r(r) is still
defined. The next r-class command will usually zap it, or even 
produce an incorrect r(r). 

Another posting suggested a wildcard yf*. Note
that may catch other variables too, such as any -yfoo-, 
depending on what else exists.

On Nov 14, 2007 10:03 AM, Nick Cox <[email protected]> wrote:

> One ` character too many.
>
> tab y, gen(yf)
> local ny = r(r)
> local vars yf1-yf`ny'

Richard Boylan

> I have a simple programming question; I am sure it is answered
> someplace but I couldn't figure out the right keywords to search for
> it (I tried for a while!)
>
> Here is what I would like to do, but STATA does not let me do that.
>
>
> *create dummy variable for variable yf
> tab y, gen(yf)
>
> *  figure out how many dummy variables I have created
> local ny = r(r)
>
> * Here is the step that does not work
> * I would like to create a list including all the dummy variables I
> created
>
> local vars "yf1-yf``ny' "

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