Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


[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 <n.j.cox@durham.ac.uk>
To   "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu>
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 
n.j.cox@durham.ac.uk 

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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index