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 1998, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 16 Mar 1998 17:04:14 -0500
Reply-To:     Ray Pass <raypass@WORLDNET.ATT.NET>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Ray Pass <raypass@WORLDNET.ATT.NET>
Subject:      Re: SUGGEST
In-Reply-To:  <9803168900.AA890079452@smtp-gw1.census.gov>
Content-Type: text/plain; charset="iso-8859-1"

At 03:12 PM 3/16/98 -0500, girish.s.patel@CCMAIL.CENSUS.GOV wrote: > CAN ANYBODY SUGGEST " CHANGES " IN THE FOLLOWING CODE TO GET " DESIRED > RESULTS " ? *************** entire original at the bottom ********************

Well, this was fun at any rate :-) Try this code. It gives the desired output, but I think I'd rather change the "DESIRED RESULTS" instead (if I could).

(I changed 'XYZ' to 'xyz' to get the desired sort order.)

data a; input idx $ cityx $ state $ active; cards; abc   1   F   4643 abc   1   N    458 abc   2   F     11 abc   2   N     21 xyz   1   F   1431 xyz   1   N    458 xyz   2   F     31 xyz   2   N     41 ; run; *--------------------------------------------------------; proc report data=a nowd headskip;

column idx cityx id city state active;

define idx / group noprint; define cityx / group noprint; define id / computed; define city / computed; define state / group; define active / analysis;

break before cityx / summarize; break after cityx / skip;

compute id / char; id = ' '; endcomp;

compute city / char; city = ' '; endcomp;

compute before cityx; state = 'TOTAL'; id = idx; city = cityx; endcomp; run; *-------------------------------------------------------------;

At 03:12 PM 3/16/98 -0500, you wrote: > CAN ANYBODY SUGGEST " CHANGES " IN THE FOLLOWING CODE TO GET " DESIRED > RESULTS " ? > > data a; > Input ID $ city $ state $ active  ; > Cards; > abc   1   F   4643 > abc   1   N    458 > abc   2   F     11 > abc   2   N     21 > XYZ   1   F   1431 > XYZ   1   N    458 > XYZ   2   F     31 > XYZ   2   N     41 > > Run; > > DATA _NULL_; > SET A ; > BY ID CITY STATE; > FILE PRINT N=PS LL=LL NOTITLES LS=100; > RETAIN SUMA  ACTIVE  0; > IF _N_ = 1 THE PUT > // @1 'ID' @9 'CITY' @20 'STATE'  @30 'ACTIVE' / ; > PUT  @1  ID       @ ; > PUT  @9  CITY     @ ; > PUT  @20 STATE     @ ; > PUT  @30 ACTIVE 4.  @ / ; > IF FIRST.CITY AND FIRST.STATE THEN DO; > SUMA=0; END; > SUMA+ACTIVE;; > IF LAST.CITY & LAST.STATE THEN > PUT @ 15 'TOTAL' @30 SUMA 4. // ; > RUN; > > <<<<<<<<<<<< output >>>>>>>>>>>> > > ID    CITY     STATE    ACTIVE > > abc   1          F         4643 > abc   1          N          458 >              TOTAL         5101 > > abc   2          F           11 > abc   2          N           21 >              TOTAL           32 > > XYZ   1          F         1431 > XYZ   1          N          458 >              TOTAL         1889 > > XYZ   2          F           31 > XYZ   2          N           41 >              TOTAL           72 > > >  <<<<<<<<< DESIRED OUTPUT >>>>>>>>>>>>> > > ID    CITY    STATE     ACTIVE > > abc   1        TOTAL      5101 >                   F       4643 >                   N        458 > > abc   2        TOTAL        32 >                   F         11 >                   N         21 > > XYZ   1        TOTAL      1889 >                   F       1431 >                   N        458 > > XYZ   2        TOTAL        72 >                   F         31 >                   N         41 >

/---------------------------------------------------------\ | Ray Pass voice: (203) 356-9540 | | ASG, Inc. fax: (203) 967-8644 | | 1100 Summer Street | | Stamford, CT 06905 e-mail: raypass@worldnet.att.net | \---------------------------------------------------------/


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