Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: using reshape


From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: using reshape
Date   Tue, 12 Sep 2006 10:22:41 +0200

Mike Frone wrote:

I obtained data in this form:
respnum_  injnum   finalwt2  gender  ir1  ir2  ir3_  ir4_1_
354            1  16151.351    male  yes    2    no      no
354            2  16151.351    male  yes    2   yes      no
354            3  16151.351    male  yes    2     .       .
354            4  16151.351    male  yes    2     .       .
354            5  16151.351    male  yes    2     .       .
 
However, because this person only experienced 2 injuries, I wanted the 
data in this form:
respnum_  injnum   finalwt2  gender  ir1  ir2   ir3_  ir4_1_
354            1  16151.351    male  yes    2     no      no
354            2  16151.351    male  yes    2    yes      no
How can I keep the number of records for a given respondent equal to the

number of injuries experienced?
----------------------------------------------------
 
I responded:
Assuming that ir3_ and ir4_1_ are 0/1 numeric variables, no/yes being
the 
value labels:
 
   drop if ir3==0 & ir4_1_==0

- but this was nonsense; it should have been:

   drop if ir3 >= . & ir4_1_ >= .
-----------------------------------------------------

Mike responded to my nonsense suggestion 

Thanks for your response.  Unfortunately, as I noted, this was a partial

record for one case.  There are many other injury characteristics. 
Moreover, a respondent may have from 1 to 5 injury event, so the number
of 
records within each value of respnum_ can range from 1 to 5.  So a
simple 
drop is unlikely to resolve the problem.
-----------------------------------------------------

I guess that you can identify "empty" observations, i.e. observations
not representing an injury, by one or more variables having a missing
value. That is the aim of 
   drop if ir3 >= . & ir4_1_ >= .

Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: sj@soci.au.dk
__________________________________________ 

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



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