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 (January 2006, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 23 Jan 2006 15:22:39 +0800
Reply-To:     Easwara Moorthy <emoorthy@BLUESINGAPORE.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Easwara Moorthy <emoorthy@BLUESINGAPORE.COM>
Subject:      Re: sas program question !
Comments: To: xamil kaisar <xaamil@YAHOO.COM>
In-Reply-To:  <20060123060731.90774.qmail@web35114.mail.mud.yahoo.com>
Content-Type: text/plain; charset="US-ASCII"

Hi,

Hope others will give a short solution! Just tried and got the solution with only datasteps!!

In your post, the required format is stated incorrectly! The required output shows sum=2 for schlid=b111. But in your test data, there is no 'sum' for b111. :) !!

data test; input schlid $ season $ student; datalines; a123 spr 2 a123 sum 2 a123 spr 2 a123 fal 3 a123 spr 1 b111 win 1 b111 win 2 b111 fal 4 ; run;

data test2(drop=season student); set test; retain spr sum fal win 0; select (season); when ('spr') do; spr=student;sum=0;fal=0;win=0; end; when ('sum') do;spr=0;sum=student;fal=0;win=0; end; when ('fal') do;sum=0;spr=0;fal=student;win=0; end; when ('win') do;sum=0;spr=0;fal=0;win=student; end; end; run;

proc sort data=test2; by schlid; run;

data final(drop=spr sum fal win rename=(spr1=spr sum1=sum fal1=fal win1=win)); set test2; by schlid; retain spr1 sum1 fal1 win1 0; if first.schlid then do;spr1=0;sum1=0;fal1=0;win1=0; end; spr1=spr1+spr; sum1=sum1+sum; fal1=fal1+fal; win1=win1+win; if last.schlid then output; run;

HTH!

Cheerz Moorthy

-----Original Message----- From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of xamil kaisar Sent: Monday, January 23, 2006 2:08 PM To: SAS-L@LISTSERV.UGA.EDU Subject: sas program question !

hi, folks: i got a question: i have a data set that needs to be flipped and then do some summation of the numeric value in the category var by the school id:

schlid season student a123 spr 2 a123 sum 2 a123 spr 2 a123 fal 3 a123 spr 1 b111 win 1 b111 win 2 b111 fal 4 ------------------

what i want is like this:

schlid spr sum fal win a123 5 2 3 . b111 . 2 4 3 ------------------------ how do i do this ? i appreciate your help !

__________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com


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