Statalist


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

Re: st: Saving labels in macros


From   "Joseph Coveney" <[email protected]>
To   "Statalist" <[email protected]>
Subject   Re: st: Saving labels in macros
Date   Tue, 12 Aug 2008 11:08:25 +0900

Max Perez Leon wrote:

I am trying to save the labels from a variable (not the code itself).  In
this case the variable is \"clas_tig\" and I want to save the labels from
the following tabulation:

----------------------------------------------------------
clas_tig Freq. Percent Cum.

INGRESOS CORRIENTES 14,722 32.12 32.12
INGRESOS DE CAPITAL 2,960 6.46 38.58
TRANSFERENCIAS 14,692 32.05 70.63
FINANCIAMIENTO 13,460 29.37 100.00
Total 45,834 100.00
----------------------------------------------------------

because i want to use this labels later for titles of graphs i am going to
do for each category of \"clas_tig\" separately.

--------------------------------------------------------------------------------

They already are saved for you.  You can get the value labels individually
by means of an extended macro function (see the example below for use with
graph titles).

In order to find out more, type

help local

and follow the hyperlink to the topic, "extended_fcn" and then look under
the heading, " Macro extended functions for extracting data attributes".

Joseph Coveney

clear *
set obs 45834
generate byte clas_tig = 0
replace clas_tig = 1 in `=14722 + 1'/l
replace clas_tig = 2 in `=14722 + 2960 + 1'/l
replace clas_tig = 3 in `=14722 + 2960 + 14692 + 1'/l
label define ValueLabels ///
0 "INGRESOS CORRIENTES" ///
1 "INGRESOS DE CAPITAL" ///
2 TRANSFERENCIAS ///
3 FINANCIAMIENTO
label values clas_tig ValueLabels
tabulate clas_tig
generate double dummy = uniform()
*
* Begin here
*
levelsof clas_tig, local(levels)
foreach level of local levels {
quantile dummy if clas_tig == `level', ///
  title("`: label (clas_tig) `level''")
}
*
* Done
*
exit


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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