Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: obtaining locals


From   Lars Korsholm <[email protected]>
To   [email protected]
Subject   st: obtaining locals
Date   Thu, 25 Sep 2003 00:10:54 +0200 (MEST)

Dear listers

I am sure that someone know a smart way to do what I want. :-)

the sort version:
Is it possible to obtain the label associated to a given value?

The long verson:
I am writing a small tabulation program. The user (also me) specify some
of the levels that a kategorical (integer) veriabel has. and for each of
these chosen levels the program  produce one line of output.

I would like the line to start with the label associated with the level
and not the integer in my loop. 

i.e. something like

program define mytab
 syntax varname, ni(numlist ..) ..
 foreach x  in numlist `ni' {
    count if `varname'=�=`x'  & ..
    di "level yyy:" `r(N)' ...
    }
end

where yyy is the contens of the label associated with varname
that corespond to the value `x'
If no label is assigned, then `x' must do.


Hope someone can help me on this one.

Best Lars


............................................
: Lars Korsholm Ph.D.,                     :
:  Department of Statistics                :
:  University of Southern Denmark          :
:  Sdr. Boulevard 23A, 2.                  :
:  DK-5000 Odense C                        :
: Phone   +45 6550 3608                    :
: Mobil   +45 3033 3617                    :
: Fax     +45 6595 7766                    :
: Mail    [email protected]              :
: Web     http://www.isd.sdu.dk/~korsholm  :
:..........................................:



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