Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Atribute variable value to String
From
Lucas Ferreira Mation <[email protected]>
To
[email protected]
Subject
st: Atribute variable value to String
Date
Tue, 22 Feb 2011 19:35:46 -0300
I have a dataset with the variables: sector_code sector_name year Y
I want to create the graph line Y year for each sector. As there
are too many sectors (500) , i want to make a loop like:
global sector_list 01112 01120 // the actual list is much longer
foreach s in $sector_list {
preserve
keep if clas_cnae=="`s'"
twoway (line Y ano) , title ( /* SOMEHOW THE VALUE IN VARIABLE
sector_name*/)
restore
}
How can I do that? I guess my question is equivlent to: how to
atribute the content of a string variable to a scalar (which I could
later use in the loop)? That would be the easyest way if I knew how.
Another solution would be to create a sector_code sector_name matrix
in mata (because they are string variables, so a Stata matrix won´t
accept) and loop over the lines of that matrix. Again, the sector list
is too big sector for manual entry. So I need a way to import string
variables from the Stata dataset to the mata matrix. How do I do that?
The mata command st_data does that but does not work for string
varibles (it imports them as missing)
thank you
Lucas Mation
Ipea-Instituto de Pesquisa Econômica Aplicada (Brasil)
*
* 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/