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 (August 2007, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 15 Aug 2007 22:33:33 -0700
Reply-To:     Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jack Hamilton <jfh@STANFORDALUMNI.ORG>
Subject:      Re: Proc means
Comments: To: Arthur Tabachneck <art297@NETSCAPE.NET>, adriano@GPP.COM.BR
In-Reply-To:  <200708152211.l7FHCwYw022513@malibu.cc.uga.edu>
Content-Type: text/plain; charset="ISO-8859-1"

I avoid PROC TRANSPOSE whenever possible, and it's almost always possible.

In this case, I would try to change the requirements so I could use PROC TABULATE or PROC REPORT instead:

===== data have; set sashelp.orsales; month = 'month' || substr(quarter,6,1); run;

proc tabulate data=have out=havetab missing; class product_category month; var total_retail_price; tables product_category='', total_retail_price=''*mean=''*month='' / box=product_category; run;

proc report data=have out=havereport (drop=_break_) missing nofs; columns product_category month , total_retail_price; define product_category / group "Product_Category"; define month / across " "; define total_retail_price / mean " "; run; =====

PROC TABULATE produces the right print output, but the output data set is in the wrong form.

PROC REPORT comes pretty close to the right print output (there are some extra blank spaces) and the output data set is right except for the variable names.

Either way, the program is easier to follow than with the PROC TRANSPOSE solution.

On Wed, 15 Aug 2007 18:11:06 -0400, "Arthur Tabachneck" <art297@NETSCAPE.NET> said: > Adriano, > > While I liked Peter's paper, I agree with Toby that a simple transpose > would give you exactly what you want. For example: > > data have; > set sashelp.orsales; > month=substr(quarter,6,1); > run; > > proc sort data=have; > by product_category month; > run; > > proc means data=have (where=(total_retail_price gt 0)); > var total_retail_price; > by product_category month; > output out=temp (drop=_:) mean=; > run; > > proc transpose data=temp out=want (drop=_:) prefix=month; > var total_retail_price; > by product_category; > id month; > run; > > HTH, > Art > ----------- > On Wed, 15 Aug 2007 16:52:10 -0700, Adriano Rodrigues - Instituto GPP > <adriano@GPP.COM.BR> wrote: > > >Hi all, > > > >I have on file with variables: > >company product number date and price. > > > >i want just make means for prices per company/product/material/month > > > >like: > >proc means data=simp maxdec=2; > > > >var pricef; > > > >class company product material month; > > > >where pricef>0; > > > >run; > > > >But i wanted results by month in columms not like proc means shows. > > > >i wanted output like > > > >company product material month1 month2 month3 > > > > 3.02 3.15 3.17 > > > >and not how appear > > > >company product material month1 3.02 > > > > month2 3.15 > > > > month3 3.17 > > > > > > > >how to do that with proc means? or i need output someway data and make > >simple proc print? > > > >thanks in advance, > > > >Adriano -- Jack Hamilton Sacramento, California jfh@alumni.stanford.org


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