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

From |
"Jared Fotis" <kingjared@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: How to tell a macro to use previous global value of that loop, akin to [_n-1] for columns |

Date |
Sun, 17 Aug 2008 14:19:44 +0200 |

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/

**Follow-Ups**:**Re: st: How to tell a macro to use previous global value of that loop, akin to [_n-1] for columns***From:*"Eva Poen" <eva.poen@gmail.com>

- Prev by Date:
**Re: st: Issue with options in addplot and lpoly** - Next by Date:
**Re: st: How to tell a macro to use previous global value of that loop, akin to [_n-1] for columns** - Previous by thread:
**st: Multicollinearity and Orthogonalization** - Next by thread:
**Re: st: How to tell a macro to use previous global value of that loop, akin to [_n-1] for columns** - Index(es):

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