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]
Re: st: create local macros named after the values of a categorial variable
From
Oliver Jones <[email protected]>
To
[email protected]
Subject
Re: st: create local macros named after the values of a categorial variable
Date
Mon, 16 Aug 2010 11:13:55 +0200
Hi everybody,
@ Maarten: Thanks a lot for your example. It let me learn a couple of nice stata-tricks.
The result your example produces is exactly what I want to get from my dataset. And that is
exactly what the workaround all ready (slowly) dose. Since I produce 60 such dummy variables
,like your x`i' variables, to indicate an observations sex, employment status (3 categories)
and agegroup (10 categories) (2*3*10=60) and I have approx 20 million observations per year I
still need quite a bit of RAM. Thus I split up the counting into 6 parts (10 dummys in each
part) and in the end put the part-results together.
@ Jeph: As with Maartens example, your hint made me aware of an option to the -tabulate-
command that might come in handy later on. Thanks for that.
But right now the code that I needed was that inspired by Sergiy:
************* begin code **************************
levelsof city_code, local(codes)
foreach code of local codes {
local i = `i' + 1 // 1, 2, ..., N; where N is the number
// of distinct codes
local city`code' = `i'
display "{text}For city code " ///
"{result}`code' {text}the value of the " ///
"local macro (named {result}city`code'{text}) is " ///
"{result}`city`code''"
}
************* end code **************************
I'm still not finished with my hopefully efficient counting program. Maybe I will never be.
For now I have to postpone it and move on to do some other stuff.
Thanks for all the help, it is much appreciated and I will be back with more questions.
Kind regards
Oliver
*
* 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/