Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <njcoxstata@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: RE: Atribute variable value to String |
Date | Wed, 23 Feb 2011 01:46:57 +0000 |
If I understand this correctly, the problem need not involve putting data into Mata only to have to pull them out again. There are various more direct solutions. Here is one. See also http://www.stata.com/support/faqs/data/foreach.html egen group = group(clas_cnae), label su group, meanonly forval i = 1/`r(max)' { twoway line Y ano if group == `i', title("`: label (group) `i''") } You will presumably want to save those graphs too. Nick Lucas Ferreira Mation >> 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. [...] * * 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/