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/