| Date: | Sun, 20 Jul 2003 22:06:17 +0100 |
| Reply-To: | Crawford <PeterDOTCrawfordATblueyonder.co.uk@Peter.BITNET> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Crawford <PeterDOTCrawfordATblueyonder.co.uk@Peter.BITNET> |
| Organization: | blueyonder (post doesn't reflect views of blueyonder) |
| Subject: | Re: SAS Reporting |
|---|
Hi Tim
deep in the proc tabulate on line doc (and possibly Lauren
Haworth's book) you'll find that tabulate tables can give simple
ratios....
This is achieved by using the concurrent total of an analysis
variable as a "percentage denominator": like:
exp * pctsum< sales >
as in:
proc tabulate missing data=your_data format=8.;
class state year;
var sales exp;
table state, year, ( sales exp)*sum=' '
exp='expense'*pctsum< sales >
='ratio %'*f=7.3
/rts=10 condense ;
run;
If you can accept using State as a by variable, you can generate
html very much like your suggestion:
proc tabulate missing data=your_data format=8.;
by state ; * the your_should be in state ;
class year quarter ;
var sales exp;
table year, ( sales exp)*sum=' '
exp='expense'*pctsum< sales >
='ratio %'*f=7.3
/rts=10 condense ;
table year*quarter, sales * sum=' ' /rts=10 ;
run;
Tabulate also has options to ensure you always get
all 4 quarters........rtfm
Good Luck
Peter Crawford
"Tim Lash" <tlash@KAHG.COM> wrote in message
news:200307182134.h6ILYNf14517@listserv.cc.uga.edu...
> I've tried a variety of approaches using Proc Report, but have been unable
> to produce the required report format. Since a computed ratio is
required,
> Proc Report seemed to be the prudent method. However, I couldn't manage
to
> report by year then by quarter using Proc Report. The report format is
> being dictated, but I'm not sure base SAS v8.02 on Windows 2000 can meet
> this requirement. Any suggestions for creating this report in SAS would
be
> greatly appreciated. Otherwise I'll take my data to another reporting
> tool. Thanks!
>
> I have the following data:
>
> State Year Qtr Sales Exp
> NY 2001 1 1000 200
> NY 2001 4 3000 100
> NY 2002 1 2000 100
> NY 2002 2 2000 100
> NY 2002 2 2000 200
> NY 2002 4 3000 400
> PA 2001 1 1000 100
> PA 2001 1 1000 100
> PA 2001 3 1000 200
> PA 2001 4 1000 100
> PA 2002 1 1000 100
> PA 2002 2 1000 100
> PA 2002 4 1000 200
> PA 2002 4 1000 200
>
> and need the following report:
>
> NY
>
> Year Sales Exp Ratio
> 2001 4000 300 7.50%
> 2002 9000 800 8.89%
>
> Year Qtr Sales
> 2001 1 1000
> 2001 2 .
> 2001 3 .
> 2001 4 3000
> 2002 1 2000
> 2002 2 4000
> 2002 3 .
> 2002 4 3000
>
> <Page Break>
>
> PA
>
> Year Sales Exp Ratio
> 2001 4000 500 12.50%
> 2002 4000 600 15.00%
>
> Year Qtr Sales
> 2001 1 2000
> 2001 2 .
> 2001 3 1000
> 2001 4 1000
> 2002 1 1000
> 2002 2 1000
> 2002 3 .
> 2002 4 2000
|