Date: Mon, 17 Mar 2008 15:48:32 -0400
Reply-To: Nathaniel.Wooding@DOM.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Nat Wooding <Nathaniel.Wooding@DOM.COM>
Subject: Re: creating one oservation from multiple observations
In-Reply-To: <31d64afc-f38e-421c-9b4e-d12c2c6eb4da@n77g2000hse.googlegroups.com>
Content-Type: text/plain; charset="US-ASCII"
Here is a sample solution that should work for you.
Data a;
input id a b c;
cards;
1 1 . 1
1 . . .
1 . . .
2 . . .
3 1 . .
3 1 . .
3 . . .
Proc Sort;
by id ;
run;
Proc summary;
output out=compressed (drop =_: ) max = ;
var a b c;
by id;
run;
Proc print;
run;
Nat Wooding
Environmental Specialist III
Dominion, Environmental Biology
4111 Castlewood Rd
Richmond, VA 23234
Phone:804-271-5313, Fax: 804-271-2977
pdzagst@GMAIL.COM
Sent by: "SAS(r)
Discussion" To
<SAS-L@LISTSERV.U SAS-L@LISTSERV.UGA.EDU
GA.EDU> cc
Subject
03/17/2008 03:33 creating one oservation from
PM multiple observations
Please respond to
pdzagst@GMAIL.COM
I have a dataset that contains multiple drugs for each patient
What that data looked like
ID medication
1 Aspirin
1 Tylenol
1 ibuprofen
2 lipitor
2 aspirin
2 multivitamin
2 hctz
3 hctz
3 tylenol
3 ibuprofen
I have rearranged the data and created new columns so it reads like
this (1= takes drug .=drug not taken);
ID Aspirin Tylenol ibuprofen lipitor multivitamin hctz
1
1 . . . . .
1 .
1 . . . .
1 . .
1 . . .
2 . . .
1 . .
2
1 . . . . .
2 . . . .
1 .
2 . . . . .
1
3 . . . . .
1
3 .
1 . . . .
3 . .
1 . . .
I would like to condense the data set so there is only one lne for
each ID number;
ID Aspirin Tylenol ibuprofen lipitor multivitamin hctz
1 1 1
1 . . .
2 1 . . 1
1 1
3 . 1
1 . . 1
How can I do this? I cannot manually overwrite each one because there
are 17000 observations. All values are eithier 1 or .
Thanks!
-----------------------------------------
CONFIDENTIALITY NOTICE: This electronic message contains
information which may be legally confidential and/or privileged and
does not in any case represent a firm ENERGY COMMODITY bid or offer
relating thereto which binds the sender without an additional
express written confirmation to that effect. The information is
intended solely for the individual or entity named above and access
by anyone else is unauthorized. If you are not the intended
recipient, any disclosure, copying, distribution, or use of the
contents of this information is prohibited and may be unlawful. If
you have received this electronic transmission in error, please
reply immediately to the sender that you have received the message
in error, and delete it. Thank you.