Statalist


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

st: RE: Re: Display labels


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Re: Display labels
Date   Tue, 10 Jun 2008 15:51:24 +0100

forvalues i = 1/3{
	di "`: label (state) `i''" 
	su a if state==`i'
} 

See -help extended fcn-. 

Nick 
[email protected] 

Janet Hill

I have a dataset which is classified by a numerical
value which has an associated label:

        state |      Freq.     Percent        Cum.
--------------+-----------------------------------
         Hard |        400       33.33       33.33
Soft. Batch 1 |        400       33.33       66.67
Soft. Batch 2 |        400       33.33      100.00
--------------+-----------------------------------
        Total |      1,200      100.00

.. tab state,nol

      state |      Freq.     Percent        Cum.
------------+-----------------------------------
          1 |        400       33.33       33.33
          2 |        400       33.33       66.67
          3 |        400       33.33      100.00
------------+-----------------------------------
      Total |      1,200      100.00
I loop over this variable with prior knowledge of the
numerical values of state
forvalues i=1(1)3{
di `i'
su a if state==`i'
....other calculations etc.
}
and this displays the numeric value of i. What I would
like to do display the label. I tried setting up a
local macro with the labels for state but this failed.
I would be grateful for some advice on the correct
syntax for this.

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index