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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Naming transformed variables in a program |

Date |
Wed, 14 May 2008 10:50:01 +0100 |

local xvar "`*'" /* no = sign */ foreach x of local xvar { generate _l`x' = L.`x' } Nick n.j.cox@durham.ac.uk Paulo Regis I have some problems when I create variables to be introduced in a user written programme. I introduce the problem using time lags though you may use time operators (l. and f.) to deal with my particular example. However, it is much simpler to explain the problem in this way so bare with me. In this example, I have program define myprogramme, eclass syntax [varlist] tokenize `varlist' local yvar="`1'" macro shift local xvar="`*'" ... end -tokenize takes the first variable of the variable list and makes it the dependent variable while the rest are the rigth-hand side variables. Now, I want to create new variables which are a transformation of the original list of variables. The simplest example is the first time lag. For the dependent variable is simple: generate _l`yvar'=l.`yvar' The problem is I couldnt find the way to make a similar transformation for the rigth-hand side variables. If `xvar' is a variable list with only one variable (x1), there is a solution generate _l`xvar'=l.`xvar' However, this solution does not work if there are more than one right-hand side variables. any idea about what I am missing? * * 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/

**References**:**st: Naming transformed variables in a program***From:*"Paulo Regis" <pauloregis.ar@googlemail.com>

- Prev by Date:
**[no subject]** - Next by Date:
**st: combining cross-sections into panel** - Previous by thread:
**st: Naming transformed variables in a program** - Next by thread:
**Re: st: Naming transformed variables in a program** - Index(es):

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