Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: local macro


From   Mitch Abdon <[email protected]>
To   [email protected]
Subject   Re: st: local macro
Date   Wed, 26 Feb 2014 12:18:04 +0800

hi, rochelle.

more appropriately, it is 'initialized' to nothing. 
in the first instance, `i' is nothing, not even zero. that's is why you get y not y0.
in the next iteration, i is defined as i = `i' + 1 which is 1, thus the y1.. and so on.



On Feb 26, 2014, at 11:53 AM, R Zhang <[email protected]> wrote:

> Dear all,
> 
> this might be a rudimentary question,
> 
> I saw the following code on UCLA stata cite
> 
> http://www.ats.ucla.edu/stat/stata/faq/doublewide.htm
> 
> *********************************
> input d1t1 d1t2 d1t3 d2t1 d2t2 d2t3 d3t1 d3t2 d3t3
> 4 5 6 5 6 5 6 7 8
> 3 4 5 4 5 4 3 4 5
> end
> 
> 
> 
> generate id = _n
> foreach v of varlist d1t1 d1t2 d1t3 d2t1 d2t2 d2t3 d3t1 d3t2 d3t3 {
>  rename `v' y`i'
>  local i = `i' + 1
> }
> *********************************
> 
> my question is:  is the i initialized to 0 (default), I ask because
> the output is
> 
>      y   y1   y2   y3   y4   y5   y6   y7   y8   id
> 
>  1.  4    5    6    5    6    5    6    7    8    1
>  2.  3    4    5    4    5    4    3    4    5    2
> 
> 
> thanks !
> 
> Rochelle
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index