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 (April 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 25 Apr 2007 21:18:33 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:      Re: help to insert summary result in a table

On Tue, 24 Apr 2007 13:31:05 -0700, yangsky66@GMAIL.COM wrote:

>data one; >input state $ city $ a b c d e; >cards; >AZ A 1 2 3 4 5 >AZ B 3 4 5 6 7 >AZ C 3 4 5 6 8 >CA M 4 2 4 5 6 >CA N 6 7 9 8 3 >; >RUN; > >I want output like this: >AZ A 1 2 3 4 5 >AZ B 3 4 5 6 7 >AZ C 3 4 5 6 8 > avg(a) avg(b) min(c) >CA M 4 2 4 5 6 >CA N 6 7 9 8 3 > avg(a) avg(b) min(c) >I want to insert my summary results into dataset by state >It looks easy and I try proc report. but I could not get it. can >anyone help >me? >thank you.

This was easy to tackle because the post included sample data ready to CPR (copy/padte/run). Good practice!

So here's a PROC TABULATE solution which comes close.

proc tabulate data=one formchar='|----|+|---+=|-/\<>*'; class state city; var a b c d e; table state * ( city all ) * f = 5.1 , ( a b ) * mean c * min (d e) * mean ; run;

------------------------------------------------------ | | a | b | c | d | e | | |-----+-----+-----+-----+-----| | |Mean |Mean | Min |Mean |Mean | |----------------------+-----+-----+-----+-----+-----| |state |city | | | | | | |----------+-----------| | | | | | |AZ |A | 1.0| 2.0| 3.0| 4.0| 5.0| | |-----------+-----+-----+-----+-----+-----| | |B | 3.0| 4.0| 5.0| 6.0| 7.0| | |-----------+-----+-----+-----+-----+-----| | |C | 3.0| 4.0| 5.0| 6.0| 8.0| | |-----------+-----+-----+-----+-----+-----| | |All | 2.3| 3.3| 3.0| 5.3| 6.7| |----------+-----------+-----+-----+-----+-----+-----| |CA |city | | | | | | | |-----------| | | | | | | |M | 4.0| 2.0| 4.0| 5.0| 6.0| | |-----------+-----+-----+-----+-----+-----| | |N | 6.0| 7.0| 9.0| 8.0| 3.0| | |-----------+-----+-----+-----+-----+-----| | |All | 5.0| 4.5| 4.0| 6.5| 4.5| ------------------------------------------------------


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