LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (July 2001, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 31 Jul 2001 08:53:06 +0300
Reply-To:     seppo s <suomase@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         seppo s <suomase@HOTMAIL.COM>
Organization: not configured in client
Subject:      Vs: Data restructuring

This kind of code seems to do Your Job: Data Orig; Infile Datalines; Length Claim 8 Type $ 10 Paid 8; Input Claim @16 Type $10. Paid; Datalines; 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 ; Run; proc Sort ; By Claim Type; Run; proc Summary ; By Claim Type; Var Paid; Output Out=NewData(Drop=_type_ _freq_) Sum=PaidSum; Run; run; Data New2; Set ; By Claim ; If First.Claim And Last.Claim Then ; Else Type='Mixed'; Run; proc Summary ; By Claim Type; Var PaidSum; Output Out=NewData2(Drop=_type_ _freq_) Sum=PaidSum; Run; run; proc print;run;

Paolo ORIFICI <Orifici@LACAJA.COM.AR> kirjoitti viestissä:sb5feb5a.084@lacaja.com.ar... > 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