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: RE: RE: Creating a group variable based on values in observations
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
RE: st: RE: RE: Creating a group variable based on values in observations
Date
Sat, 21 May 2011 11:35:04 +0100
I missed out a crucial line:
gen signature = ""
bysort id (market) : replace signature = signature[_n-1] + string(market)
by id : replace signature = signature[_N]
Nick
[email protected]
Nick Cox
Going for the interpretation that 1 ... 7 are days of the week, then
another way to do it would have been
gen signature = ""
bysort id (market) : replace signature = signature[_n-1] + string(market)
which creates signatures such as "135", which as Bert says can be
mapped to integers 1 up with -egen, group()-. Strictly, -group()- is
an -egen- function, not an option.
Use the -label- option and they remain intelligible.
Use -tabulate- and you get indicator variables.
*
* 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/