Owing to the current shortcomings with ESP, I will assume you have the regions coded in some kind of string variable (say 'region')...?
In this case, you can create a region number variable ('regnum') with
encode region, gen(regnum)
The missing regions do not pose a problem to -reshape- (unless they are missing from all companies, but then I guess you wouldn't care about them). They will come through as missing rather than zero, so you might want to recode these afterwards using -recode- or -mvencode-.
David
[email protected]
-----Original Message-----
From: Michael Blasnik [mailto:[email protected]]
Sent: 01 December 2004 16:49
To: [email protected]
Subject: st: Re: 'Transposing' data- follow up question
If the data are in order by region within company, then you can just
generate the region variable as:
bysort company: gen int region=_n
But if there are missing regions in the middle of the data for a company,
then Stata would need ESP to determine which observations correspond to
which regions. I don't think ESP will be available until Stata 11 :)
Michael Blasnik
[email protected]
----- Original Message -----
From: "Shyam Kumar" <[email protected]>
To: <[email protected]>
Sent: Wednesday, December 01, 2004 11:35 AM
Subject: st: 'Transposing' data- follow up question
> Many thanks to all of you who responded yesterday. The
> reshape wide command seems the most applicable. I do
> have an additional question though. My data set does
> not contain a separate variable that I can specify
> under j. Further, the number of observations (under
> the j variable, if there was one) also vary. In other
> words my data set is as follows:
>
> Company identifier Sales by region
> X 25
> X 40
> Y 125
> Y 100
> Y 65
>
> I do not have a variable, region that is coded with
> values 1,2,3. Also in the above example X's sales in
> region 3 are 0, but there is no separate row for X for
> region 3 with a value 0. Any insights on how I can
> overcome these problems would be much appreciated.
>
> Thank you once again.
>
> Shyam
>
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/