Dear Martin,
I apologize the code was completely perfect. I changed some variable names and that is why i had the problem.
Please ignore my previous posting.
Many thanks,
Nick
--- On Mon, 12/28/09, Martin Weiss <[email protected]> wrote:
> From: Martin Weiss <[email protected]>
> Subject: Re: st: Ungroup grouped data
> To: [email protected]
> Date: Monday, December 28, 2009, 5:49 PM
> <>
>
> Here is a reasonably short solution for you! Have a happy
> new year :-)
>
> ***
> clear*
>
> inp byte(counts cases var1 var2)
> 1 1 0
> 2
> 2 2 1
> 2
> 4 7 0
> 0
> 4 12
> 1 1
> 1 3 2
> 2
> 2 7 1
> 0
> 0 2 2
> 0
> 0 13
> 2 1
> end
>
> //to 47 cases
> expand cases
>
> //outcome must be assigned separately
> bys var*: gen byte outcome=inrange(_n,1,counts)
> la def mylabel 0 "outcome not observed" 1 "outcome
> observed"
> la val outcome mylabel
>
> //get rid of "counts" and "cases"
> drop c*
>
> li, noo sepby(var*)
>
> ***
>
>
> HTH
> Martin
> -------- Original-Nachricht --------
> > Datum: Mon, 28 Dec 2009 07:37:57 -0800 (PST)
> > Von: Nikolaos Pandis <[email protected]>
> > An: [email protected]
> > CC: [email protected]
> > Betreff: st: Ungroup grouped data
>
> > Hi to all,
> >
> > I have the dataset below which I would like to expand
> and list each
> > observation in one row.
> >
> > The counts variable shows the number of individuals
> with the outcome.
> > The cases variable shows the number of individuals
> that share the
> > covariate pattern for the variables var1 and var2.
> > The sum of cases (47) shows the total number of
> exposed individuals and
> > the sum of counts (14) shows the total number of
> individuals,from the
> > exposed, with the outcome.
> >
> > The fully expanded dataset should list 47 observations
> (=sum of cases).
> >
> > counts cases
> var1 var2
> > 1 1
> 0 2
> > 2 2
> 1 2
> > 4 7
> 0 0
> > 4 12
> 1 1
> > 1 3
> 2 2
> > 2 7
> 1 0
> > 0 2
> 2 0
> > 0 13
> 2 1
> >
> > Your help would be appreciated.
> >
> > Best wishes,
> >
> > Nick
> >
> >
> >
> > *
> > * 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/
>
> --
> Preisknaller: GMX DSL Flatrate für nur 16,99 Euro/mtl.!
> http://portal.gmx.net/de/go/dsl02
> *
> * 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/
>
*
* 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/