Statalist The Stata Listserver


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

Re: st: using reshape


From   frone@ria.buffalo.edu
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: using reshape
Date   Tue, 12 Sep 2006 12:52:08 -0400

Svend,

Thanks again for your suggestions.

You're right that I could create a set of -drop- statements to remove all 
null records (where all reshaped variables are missing) so that -reshape- 
would create the unbalanced data set I need.  Despite my general aversion 
to using SPSS, I took a look at their version of -reshape-, called 
-restructure-.  There is a handy option to drop all null records, which 
easily creates unbalanced data sets.  It would be nice if Stata's 
-reshape- command had such an option.  Given the likelihood of adding new 
variables as the data analysis progresses, I will likely use SPSS to 
reshape my data.

Mike Frone

****************************************************************
Michael R. Frone, Ph.D.
Senior Research Scientist
Research Institute on Addictions
State University of New York at Buffalo
1021 Main Street
Buffalo, New York 14203

Office:    716-887-2519
Fax:        716-887-2477
E-mail:     frone@ria.buffalo.edu
Internet: http://www.ria.buffalo.edu/profiles/frone.html
****************************************************************



"Svend Juul" <SJ@SOCI.AU.DK> 
Sent by: owner-statalist@hsphsun2.harvard.edu
09/12/2006 04:22 AM
Please respond to
statalist@hsphsun2.harvard.edu


To
<statalist@hsphsun2.harvard.edu>
cc

Subject
Re: st: using reshape






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/


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