Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: problem before reshape

From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: problem before reshape
Date   Thu, 23 Oct 2003 11:31:35 +0100

ann fitzmaurice

> i have 16 variable mm1 mm2 mm3 etc and exh variable has 16
> associated
> variabes (events) eg mm1_1 mm2_2 mm2_3 etc
>                      mm2_1 mm2_2 mm2_3 etc
> I am tring to use reshape and used the following
> reshape long mmi mm1 mm2 mm3 mm4 mm5 mm6 mm7 mm8 mm9 mm10
> mm11 mm12 mm13
> mm14 mm15, i(caseid)as the mmi , mm1 , mm2 etc are the stubs
> unfortunately i get an error message r(498) which i have looked at

-reshape- issues r(498) in various circumstances, with
different error messages, as inspection
of the code makes clear.

In your case, either the stubs should be mm1_ mm2_ etc. or
you need to specify the -string- option. That is, you have
to think about how the underscore will be treated, just to
Stata is an integral part of the variable name.

I am not clear where -mmi- fits into your scheme.

> i think the problem is that not all the  blocks of data was
> collected
> e.g for mm10 , all the associated variables are blank
> my question is
> is there a way in stata that i can identify which block of
> data are blank
> for all the associated variables and then drop this blank?

By "blank" I guess you mean missing. If you

. search drop missing

you will get pointed to a program -dropmiss- dedicated
to this.

> a complication is that for the higher number variables
> within each block
> there may also be variables which are blank , but i presume
> that i would
> need to keep these for the reshape - or if i drop these as
> well will stata
> still reshape long even though the number of variables
> associated with
> each block will not be the same

Stata does not require equal numbers of variables associated
with each stub. So given e.g.

id a1 a2 a3 b1 b2

. reshape long a b , i(id)

the consequence is just a block of missings on -b- for
the block  for which -_j- is 3.

> At some point i will need to apply to other data sets which
> may or may not
> have collected the data eg for mm10 and associated variables (mm10_1
> mm10_2 mm10_3 etc) in survey one this may not have been
> collected but will
> have been collected in survey 2

[email protected]

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index