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, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: how to keep labels when using foreach

From   anne broe <>
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

*   For searches and help try:

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