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 (May 2007, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 7 May 2007 10:59:06 -0400
Reply-To:     Florio Arguillas <foa2@CORNELL.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Florio Arguillas <foa2@CORNELL.EDU>
Subject:      Re: Simple Output & Summarizing
Comments: To: Daniel Reyes <junkdalejreyes@YAHOO.COM>
In-Reply-To:  <486095.36266.qm@web34201.mail.mud.yahoo.com>
Content-Type: text/plain; charset="us-ascii"; format=flowed

One approach if you have more than 2 categoires i.e., not just "A" and "Z".

data have; infile cards; input STCOU LOC_CODES $; cards; 01011 A90 01011 A4H 01011 AP9 01011 Z90 02011 Z78 02011 ZA7 02011 Z99 03011 A09 03011 A0J 03011 Z45 03011 Z58 ; RUN;

PROC SQL; CREATE TABLE NEED AS SELECT STCOU, SUBSTR(LOC_CODES,1,1) AS LOC_CODES_1stCHAR, COUNT(SUBSTR(LOC_CODES,1,1)) AS NUMLOC_CODES FROM HAVE GROUP BY STCOU, LOC_CODES_1stCHAR; QUIT;

PROC TRANSPOSE DATA = NEED OUT = NEED (DROP = _NAME_) PREFIX = TTL; VAR NUMLOC_CODES; ID LOC_CODES_1stCHAR; BY STCOU; RUN;

DATA NEED; LENGTH STCOU TTL 8.; SET NEED; TTL = SUM(OF TTL:); RUN;

At 10:06 AM 5/7/2007, Daniel Reyes wrote: >My summarizing skills in SAS are atrocious. > >I need to go from this: >STCOU LOC_CODES >01011 A90 >01011 A4H >01011 AP9 >01011 Z90 >02011 Z78 >02011 ZA7 >02011 Z99 >03011 A09 >03011 A0J >03011 Z45 >03011 Z58 > >To this: > >STCOU TTL TTL 'A' TTL 'Z' >01011 4 3 1 >02011 3 0 3 >03011 4 2 2 > >Any ideas? >Thanks... > >__________________________________________________ >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