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 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 18 May 2007 22:06:34 -0400
Reply-To:     "data _null_;" <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_;" <datanull@GMAIL.COM>
Subject:      Re: PROC MEANS classes, by-variables, or both?
Comments: To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@howles.com>
In-Reply-To:  <200705190102.l4IGRaFF003864@mailgw.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Why not use IDGROUP so that when the order variable either character or numeric you can still get desirable results in one step.

data work.team; input TEAM:$3. DATE:$8. H_C F_P E_P; cards; ABC 20050714 18 125 32 ABC 20050715 18 136 35 ABC 20050716 14 92 20 ABC 20050717 14 98 16 ABC 20050718 18 118 38 ABC 20050719 18 126 37 ;;;; proc summary data=work.team nway; by team h_c notsorted; output out=work.mean(drop=_:) mean(f_p e_p)= idgroup(min(date) out(date)=from) idgroup(max(date) out(date)=to) ; run; proc print; run;

On 5/18/07, Howard Schreier <hs AT dc-sug DOT org> <nospam@howles.com> wrote: > On Fri, 18 May 2007 16:50:11 -0400, data _null_; <datanull@GMAIL.COM> wrote: > > >You need to create SEQ... then use it in your class statement too. > > > >data work.team; > > input TEAM:$3. DATE:yymmdd. H_C F_P E_P; > > format date date9.; > > cards; > >ABC 20050714 18 125 32 > >ABC 20050715 18 136 35 > >ABC 20050716 14 92 20 > >ABC 20050717 14 98 16 > >ABC 20050718 18 118 38 > >ABC 20050719 18 126 37 > > ;;;; > >proc sort data=work.team; > > by team date; > > run; > >data work.teamSeq; > > set work.team; > > by team h_c notsorted; > > if first.team then seq = 0; > > if first.h_c then seq + 1; > > run; > >proc print; > > run; > >proc summary data=work.teamseq nway; > > class team seq h_c; > > output out=work.mean(drop=_:) mean(f_p e_p)=; > > run; > >proc print; > > run; > > Why not do it in one step (after sorting by TEAM and DATE, if necessary): > > proc summary data=team; > by team h_c notsorted; > output out=mean(drop=_:) > min(date)=from max(date)=to mean(f_p e_p)=; > run; > > As a bonus, you get reference dates instead of meaningless sequence numbers. > > Output: > > TEAM H_C from to F_P E_P > > ABC 18 14JUL2005 15JUL2005 130.5 33.5 > ABC 14 16JUL2005 17JUL2005 95.0 18.0 > ABC 18 18JUL2005 19JUL2005 122.0 37.5 > > Aside: Welcome, Floyd. Congratulations on picking an unusually accurate and > germane subject heading for your first post here. It indeed was all about > CLASS vs. BY. > > > > >On 5/18/07, Floyd Moseby <floydmoseby@gmail.com> wrote: > >> Hi folks, this is my first post to this group. I'm a new SAS > >> programmer (not a student), and could use some advice. > >> > >> I am working on some very basic performance analysis within my > >> department. Let's assume that my table has 5 variables in the > >> following order: > >> > >> Team (character) > >> Date (character) > >> Head_Count (numeric...cannot be character) > >> Files_Processed (numeric) > >> Errors_Produced (numeric) > >> > >> I need to write a PROC MEANS procedure that displays the mean values > >> of Files_Processed and File_Errors, by Team and Head_Count. However, > >> the Head_Count variable fluctuates over time, and I need to report the > >> average values in chronological order. My intended output should and > >> will have repeat values for Head_Count by team, but must be output in > >> chronological order despite the Date variable being NOT present. > >> > >> Here's a quick example; please forgive the formatting: > >> > >> [TEAM] [DATE] [H_C] [F_P] [E_P] > >> ABC 20050714 18 125 32 > >> ABC 20050715 18 136 35 > >> ABC 20050716 14 92 20 > >> ABC 20050717 14 98 16 > >> ABC 20050718 18 118 38 > >> ABC 20050719 18 126 37 > >> > >> My output table should look like this: > >> > >> [TEAM] [SEQ] [H_C] [F_P] [E_P] > >> ABC 01 18 130.5 33.5 > >> ABC 02 14 95 18 > >> ABC 03 18 122 37.5 > >> > >> The date variable will lose its relevance, but I'll still need a > >> variable to describe the chronological order of the particular mean > >> values by Team and by Head_Count. I've tried variations of the > >> following: > >> > >> PROC MEANS DATA=Metrics NORPRINT MEAN; > >> CLASS Head_Count; > >> BY Team; > >> VAR Files_Processed Errors_Produced; > >> OUTPUT OUT=Performance (drop= _TYPE_) mean=; > >> RUN; > >> > >> However, I still get the mean values displayed in ascending order by > >> Team by Head Count. I'm having a tough time finding references to > >> similar problems online and in print. > >> > >> Does any know how I can resolve this part of my code? I appreciate > >> any help you can offer! > >> > >> Floyd Moseby > >> >


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