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 (July 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 26 Jul 2001 09:39:06 -0400
Reply-To:     "Diskin, Dennis" <Dennis.Diskin@PHARMA.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Diskin, Dennis" <Dennis.Diskin@PHARMA.COM>
Subject:      Re: Data restructuring
Comments: To: Paolo ORIFICI <Orifici@LACAJA.COM.AR>
Content-Type: text/plain

Paolo,

Here's one way using datastep programming logic:

data test; length type $ 8; INPUT CLAIM TYPE PAID;

cards; 1 body 100 1 body 70 1 body 30 2 material 5 2 material 7 3 body 70 3 material 3 3 material 8 3 body 30 4 material 12 4 body 20 5 body 120 ;

proc sort data=test; by claim;

data test(drop=paid type);; set test; by claim; retain type_1 paid_sum; if first.claim then do; paid_sum = 0; type_1 = type; end; paid_sum + paid; if type ne type_1 then type_1 = 'mixed'; if last.claim;

proc print;

run;

OBS CLAIM TYPE_1 PAID_SUM

1 1 body 200 2 2 material 12 3 3 mixed 111 4 4 mixed 32 5 5 body 120

> -----Original Message----- > From: Paolo ORIFICI [SMTP:Orifici@LACAJA.COM.AR] > Sent: Thursday, July 26, 2001 8:44 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Data restructuring > > HI list members, > > I'm new to SAS. I want to restructure my SAS dataset in order to obtain a > single observation from multiple records. > > The original data set has the following structure: > > Claim Type Paid > 1 body 100 > 1 body 70 > 1 body 30 > 2 material 5 > 2 material 7 > 3 body 70 > 3 material 3 > 3 material 8 > 3 body 30 > 4 material 12 > 4 body 20 > 5 body 120 > > > The new dataset should have this new structure: > > Claim Type_1 Paid_sum > > 1 Body 200 > 2 Material 12 > 3 Mixed 111 > 4 Mixed 32 > 5 Body 120 > > > > Thank you in advance. > > Paolo Orifici


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