|
Hi,
If you only have a few drugs out of many possible ones, then you might try something like this below (NOT tested):
-Mary
data set2;
set set1;
by id;
retain aspirin tylenol;
if trim(medication)='Aspirin' then aspirin=1;
if trim(medication)='Tylenenol' then tylenol=1;
if last.id then
do;
output;
aspirin=0;
tylenol=0;
end;
run;
----- Original Message -----
From: pdzagst@GMAIL.COM
To: SAS-L@LISTSERV.UGA.EDU
Sent: Monday, March 17, 2008 2:33 PM
Subject: creating one oservation from multiple observations
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!
|