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]
Re:st: Programming a slightly complex list of independent variables
From
"Clyde Schechter" <[email protected]>
To
[email protected]
Subject
Re:st: Programming a slightly complex list of independent variables
Date
Wed, 6 Apr 2011 07:30:38 -0700
"Nic," I think if you modify your code as follows it will do what you want:
foreach y of varlist d* {
local laby : variable label `y'
foreach x of varlist s* {
local labx : variable label `x'
local prex = substr("`x'",1,3)
foreach z of varlist f* {
local labz : variable label `z'
local prez = substr("`z'",1,2)
unab svars: s* // STORE ALL THE s* VARIABLE NAMES IN A MACRO svars
local svars: list svars - x // REMOVE `x' FROM `svars'
unab fvars: f* // STORE ALL THE f* VARIABLE NAMES IN A MACRO fvars
local fvars: list fvars - z // REMOVE `z' FROM `fvars'
// REVISE THE VARIABLE LIST FROM THE ORIGINAL CODE
regress `y' `x' `z' i`prex'`prez' g* c* e* `svars' `fvars'
Hope this helps.
Clyde Schechter
Albert Einstein College of Medicine
Bronx, NY, USA
Please note new e-mail address: [email protected]
*
* 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/