Sacrificial First Line...
Please excuse the elementary nature (hopefully) of this question, but
I've tried all of the key words to search for in the archives, etc. am
at a lose as to how to describe the question to the search engine.
What is the proper code to tell stata to take the previous value of
`X' in the associated "global" for the macro?
I am writing a macro to record the year and value of a firm
disappearing from the data set, meaning that if a firm exits in year 7
I want to the macro to record the value in year 6. Firms are in rows
and years are in columns with the associated varname. How do I tell
the macro to take the previous year (6) for that loop's "X" value (7)
in the macro itself?
Example with a global of 1 to 10:
replace LHS_NMCE_`X'=5 if LHS_NMCE_`X'==. & LHS_NMCE_`X-1'=1
Here I try `X-1', but have also attemped (`X'-1), `(X-1)' and
`X[_n-1]' to no avail. Thanks in advance.
Best,
Jared
*
* 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/