Charles
your OUTPUT statement requested statistics SUM and N. My output window from PROC MEANS didn't show the N statistic because you put SUM in the proc means statement but not N, so I'm a little confused which is what you wanted.
So with nothing else to go on, I'll assume both.
I generated this test data[pre]data _9SSummary ;
do _1 = 1 to 3 ;
do _2 = 2 to 4 by 2 ;
do _3 = 3 to 9 by 3 ;
_4= (_1*10 +_2 )*10 +_3 ;
if not mod( _4, 7 ) then _4=. ; ;
output ;
end; end; end;
stop ;
run ;[/pre]***** I wanted to have an analysis variable occasionally missing;
When you need only one statistic (say, SUM), PROC MEANS is your best friend
proc means data= _9SSummary nway ;
var _: ;
output sum= out= _9SSummaryA( drop= _type_ _freq_ ) ;
rurn ;
Then PROC MEANS assumes that the statistics should be named like the original variables from which they are derived.
You can even leave out that VAR statement and PROC MEANS will provide the statistics for all numeric variables when that is what you need.
There is another excellent feature in PROC MEANS ----> more than one OUTPUT statement can be used.
So, if you really needed two statistics - create a separate output for each stat.
OUTPUT OUT= stat1 SUM= ;
OUTPUT OUT= stat2 N= ;
Of course you will want to bring the results back together again - how about[pre]proc means data=_9SSummary n sum maxdec= 0;
var _: ;
output out=_9SSummaryS sum= ;
output out=_9SSummaryN n= ;
run;
data together ;
set _9SSummaryN(in= stat2)
_9SSummaryS(in= stat1) ;
drop _type_ _freq_ ;
if stat1 then _stat_ = 'SUM' ;else _stat_ ='N' ;
run ;
proc transpose out= _9SSummaryA( rename= _name_= Variable) ;
id _stat_ ;
run ;
proc print ;
run ; [/pre]From my brief test data, I got this listing[pre]
Obs Variable N SUM
1 _1 18 36
2 _2 18 54
3 _3 18 108
4 _4 15 3450
[/pre]
So Charles, what was it you wanted?
peterC
looks like I type too slowly ! data _null_; seems to have made my suggestions redundant ;-(
Message was edited by: Peter.C