LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 17 Mar 2008 15:35:46 -0500
Reply-To:   Mary <mlhoward@avalon.net>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Mary <mlhoward@AVALON.NET>
Subject:   Re: creating one oservation from multiple observations
Comments:   To: pdzagst@GMAIL.COM
Content-Type:   text/plain; charset="iso-8859-1"

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!


Back to: Top of message | Previous page | Main SAS-L page