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]

st: local macro


From   R Zhang <[email protected]>
To   [email protected]
Subject   st: local macro
Date   Tue, 25 Feb 2014 22:53:40 -0500

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/


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