Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[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" <clyde.schechter@einstein.yu.edu>
To   statalist@hsphsun2.harvard.edu
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: clyde.schechter@einstein.yu.edu

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


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