I don't understand how Shyam knows that it is region
3 that is missing.
Nick
[email protected]
David Harrison
> 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-.
Michael Blasnik
> 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 :)
Shyam Kumar
> > 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.
*
* 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/