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]

st: RE: Creating a group variable based on values in observations


From   "Chris Parker" <cparker.phd2007@london.edu>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Creating a group variable based on values in observations
Date   Fri, 20 May 2011 23:04:42 +0100

Hi,

I think I have a solution. My data is a bit too big to do this all at
once (reshape gives a return code telling me productmarket takes on too
many values) but here is what works in case anyone runs into a similar
problem:

. gen marketdup = market
. reshape wide market, i(date) j(marketdup)
. egen openmarkets = concat(market*), punc(_)
. encode openmarkets, gen(groupid)
. drop openmarkets
. reshape long
. drop marketdup

Chris

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Chris Parker
Sent: Friday, May 20, 2011 9:36 PM
To: statalist@hsphsun2.harvard.edu
Subject: st: Creating a group variable based on values in observations

Hi Statalist,

I have a problem that's been troubling me for a while now. I have daily
prices for several products in several markets over time. I use the data
to measure price dispersion as the coefficient of variation of prices on
a day for a product. However, not every market is open on every day.
Systematic differences between the markets that are open (such as
average distance between markets, percent of markets of type A, etc.)
could impact price dispersion, so I need to control for this. For each
product I would like to create a variable that lists which group of
markets was open on each day (openmarkets in the example below). I could
then encode this variable and include i.groupid which controls for these
differences.

Example data for one of the products:

day	market		openmarkets	groupid
1	1		1-2-3-4-5	1
1	2		1-2-3-4-5	1
1	3		1-2-3-4-5	1
1	4		1-2-3-4-5	1
1	5		1-2-3-4-5	1
2	2		2-3-5		2
2	3		2-3-5		2
2	5		2-3-5		2
3	1		1-3-4-5		3
3	3		1-3-4-5		3
3	4		1-3-4-5		3
3	5		1-3-4-5		3
4	2		2-3-5		2
4	3		2-3-5		2
4	5		2-3-5		2

Any ideas?

Chris

______________________________________________________________________

This email has been scanned by the MessageLabs Email Security System on
behalf of the London Business School community.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

*
*   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/

______________________________________________________________________

This email has been scanned by the MessageLabs Email Security System on
behalf of the London Business School community.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________

This email has been scanned by the MessageLabs Email Security System
on behalf of the London Business School community.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

*
*   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