Statalist


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

st: Naming transformed variables in a program


From   "Paulo Regis" <pauloregis.ar@googlemail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Naming transformed variables in a program
Date   Wed, 14 May 2008 10:35:57 +0100

Dear All,

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?

Cheers

Paulo
*
*   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/



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