|
On Thu, 6 Jul 2006 14:26:01 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:
>Howard ,
>
>True, Proc Means can create a data set but it is not its default where as
>Proc Summarys default is to create a data set.
An experiment. First create a data set so that _LAST_ will be loaded and the
DATA= option will not be needed in PROC SUMMARY.
data; x=1; run;
Now the only *required* code in PROC SUMMARY is the simple
proc summary;
run;
However, there is no default output (either data set or listing), and we get
ERROR: Neither the PRINT option nor a valid output statement has been given.
NOTE: The SAS System stopped processing this step because of errors.
It seems to me this should be a WARNING at most, but it isn't. Anyway, while
no other code element is required, either the PRINT option *or* an OUTPUT
statement is necessary to avoid the error. Either
proc summary;
output;
run;
or
proc summary print;
run;
works successfully.
So PROC SUMMARY does not create an output data set by default, and it seems
to be neutral as to whether results are stored or displayed.
> The final solution will
>entail some transposition of the data which requires a data set. Thus the
>first problem is get data set to transpose (proc summary) and second problem
>turn the sucker into the desired data structure (Proc Transpose) and Data
>Step.
I think it's simpler to transpose first, then summarize. Try:
data two;
set one;
obsnum + 1;
run;
proc transpose data=two out=three;
by obsnum;
run;
proc summary data=three nway;
class _name_;
var col1;
output out=four(drop=_type_ _freq_) mean=Mean p90=P90 p95=P95;
run;
If performance is a concern, the transposition could be done as a DATA step
view; fewer passes and less I/O, but more complicated code.
>
>
>
>Since I havent seen a solution to the question yet:
>
>
>Data One ;
>Infile Cards ;
>Input X1 X2 X3 ;
>Cards ;
>1 2 3
>4 5 6
>5 6 7
>6 7 8
>7 8 9
>;
>run ;
>
>Proc Summary
> Data = One Nway ;
> Var X1 X2 X3 ;
> Output Out = Stats ( Drop = _Type_ _Freq_ )
> Mean( X1 ) = AvgX1
> Mean( X2 ) = AvgX2
> Mean( X3 ) = AvgX3
>
> P90( X1 ) = P90X1
> P90( X2 ) = P90X2
> P90( X3 ) = P90X3
>
> P95( X1 ) = P95X1
> P95( X2 ) = P95X2
> P95( X3 ) = P95X3
>;
>Run ;
>
>
>Proc Transpose
> Data = Stats
> Out = StatsB ;
>Run ;
>
>
>Data StatsB ;
>Set StatsB ;
>Var = Substr( _Name_ , 4 ) ;
>Name = Substr( _Name_ , 1 , 3 ) ;
>Run ;
>
>
>Proc Sort
> Data = StatsB ;
> By Var ;
>Run ;
>
>Proc Transpose
> Data = StatsB
> Out = Need ( Drop = _Name_ ) ;
> by Var ;
> Id Name ;
>Run ;
>
>
>
>Probably a little verbose but I was wanting to be as explicit as possible.
>
>Toby Dunn
>
>
>
>
>
>From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
>Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: output of Proc means
>Date: Thu, 6 Jul 2006 10:02:20 -0400
>
>On Thu, 6 Jul 2006 01:20:36 +0000, toby dunn <tobydunn@HOTMAIL.COM> wrote:
>
> >Li ,
> >
> >Use Proc Summary, it was designed to create ouput datasets.
> >
>
>MEANS can also create a data set. The catch I think is the *shape* of the
>data set. Li Zhang wants a separate observation in the output for each
>original variable. PROCs MEANS/SUMMARY and TABULATE create output data sets
>with all of the stats for all of the variables in a single observation.
>That's true whether the output is generated using an option in the proc code
>or using ODS. See http://tinyurl.com/fl8tw
>
> >
> >Toby Dunn
> >
> >
> >From: Li Zhang <zhanglitt@YAHOO.COM>
> >Reply-To: Li Zhang <zhanglitt@YAHOO.COM>
> >To: SAS-L@LISTSERV.UGA.EDU
> >Subject: output of Proc means
> >Date: Wed, 5 Jul 2006 17:34:56 -0700
> >
> >The MEANS Procedure :
> >
> >proc means mean p90 p95 data=a maxdec=2;
> >run;
> >
> >will produce an output that looks like:
> >
> >
> >Variable Mean 90th Pctl 95th Pctl
> >x1 2.05 2.75 2.99
> >x2 3.06 3.99 4.12
> >x3 -1.02 1.20 1.35
> >
> >I am wondering if I can create a SAS data set that
> >contains the same information and has the same format
> >as this output.
> >
> >Thank you
> >
> >__________________________________________________
> >Do You Yahoo!?
> >Tired of spam? Yahoo! Mail has the best spam protection around
> >http://mail.yahoo.com
|