Date: Wed, 27 Jun 2007 20:01:05 +0000
Reply-To: iw1junk@COMCAST.NET
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Ian Whitlock <iw1junk@COMCAST.NET>
Subject: Re: SORT needed before PROC SUMMARY NWAYS
Summary: When you want things that aren't there define the universe.
Summary2: Bug or feature?
#iw-value=1
In response to Howard, Mikeeeeeeeeeeeee wrote in part:
> Neither you, nor I, nor most SAS users would believe that PROC SUMMARY
> would actually make up combinations of pairs of values that do not exist
> in the SAS data set being summarized, e.g. SEX=Z AGE=299792458. Of
> course it would be bounded by what is in the SAS data set being
> summarized. I don't get it?!?!?!?
Perhaps you meant to say, that you need to define the universe. Consider:
proc format ;
value age
10 = '10'
11 = '11'
12 = '12'
13 = '13'
14 = '14'
15 = '15'
16 = '16'
299792458 = "wow!"
;
value $sex
"F" = "female"
"M" = "male"
'Z' = "unkown"
;
run ;
proc means data = class completetypes;
class sex age / preloadfmt exclusive order = data;
format sex $sex. age age. ;
output out=summary ;
run ;
This SUMMARY dataset knows about values that aren't there and gives the
count as zero. However, as an added feature, you get the old style MEANS
output. If you want it in the contemporary PROC SUMMARY style then you need
to trick it. For example,
proc means data = class completetypes;
class sex age / preloadfmt exclusive order = data;
var height ;
format sex $sex. age age. ;
output out=summary (drop = height) n=;
run ;
Ian Whitlock