Bookmark and Share

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]

st: how to keep labels when using foreach


From   anne broe <[email protected]>
To   [email protected]
Subject   st: how to keep labels when using foreach
Date   Wed, 13 Mar 2013 11:38:02 +0000

Dear all

Im using -foreach- but seem to loose all my value labels when doing so.
How can I keep the labels in the output from -foreach-?

this is my do file

foreach xx in m_agegr==0 m_agegr==15 m_agegr==20 m_agegr==25
m_agegr==30 m_agegr==35 m_agegr==40 m_agegr==45 smoking_status==0
smoking_status==1 smoking_status==2 smoking_status==3    {
        use Work\Temp4, clear
        display "`xx'"
        keep if `xx'
        gen atc_yes = 1 if ga_atc==1
        gen atc_no = 1 if ga_atc==0
        collapse (sum) atc_yes atc_no
        gen str30 group="`xx'"
        if "`xx'" != "m_agegr==0" append using Work\Q4
    save Work\Q4, replace
    }


Thanks
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index