| Date: | Wed, 21 Jul 2010 13:25:10 -0400 |
| Reply-To: | msz03@albany.edu |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Mike Zdeb <msz03@ALBANY.EDU> |
| Subject: | Re: summary statistics of all variables |
| Content-Type: | text/plain;charset=iso-8859-1 |
hi ... given the observation on standard MEANS output, rather than ODS OUTPUT
how about output to a file then read the results into a data set ...
* make some missing data in sashelp.class;
data class;
set sashelp.class;
if ranuni(999) le .3 then call missing(of _all_);
run;
* redirect output to file;
filename means temp;
proc printto print=means;
run;
proc means data=class n nmiss min max;
run;
proc printto;
run;
* read proc means output;
data stats;
infile means truncover;
input variable : $32. (n nmiss min max) (??);
if max;
run;
proc print data=stats;
run;
Obs variable n nmiss min max
1 Age 13 6 11.0 15
2 Height 13 6 51.3 69
3 Weight 13 6 50.5 133
--
Mike Zdeb
U@Albany School of Public Health
One University Place (Room 119)
Rensselaer, New York 12144-3456
P/518-402-6479 F/630-604-1475
> From the replies you have received it appears that a data set with the
> structure you require is somewhat difficult to achieve. What with all
> that transposing and the rest.
>
> Interestingly the output closely resembles the printed output from PROC MEANS.
>
> The MEANS Procedure
>
> N
> Variable Miss N Minimum Maximum
> Age 395 19 11.0000000 16.0000000
> Height 395 19 51.3000000 72.0000000
> Weight 395 19 50.5000000 150.0000000
> Stores 19 395 1.0000000 41.0000000
> Sales 19 395 325.0000000 1298717.00
> Inventory 19 395 374.0000000 2881005.00
> Returns 19 395 10.0000000 57362.00
>
> But when you ask for this data via ODS OUTPUT the data structure is
> very different. And the transposing begins.
>
> The ODS output from PROC CORR does resemble the desired layout but you
> don't get to specify statistics and NMISS is not available, but could
> be calculated.
>
> ods listing close;
> proc corr nocorr data=test;
> ods output "Simple Statistics"=stats /*"Variables Information"=Varinfo*/;
> run;
> ods listing;
> Ods trace off;
> proc print data=stats;
> run;
>
> Obs Variable NObs Mean StdDev Sum
> Min Max
>
> 1 Age 19 13.3 1.49 253.00000
> 11.00 16.00
> 2 Height 19 62.3 5.13 1184
> 51.30 72.00
> 3 Weight 19 100.0 22.77 1901
> 50.50 150.00
> 4 Stores 395 11.6 8.87 4601
> 1.00 41.00
> 5 Sales 395 85700.2 129107.2 33851566
> 325.00 1298717
> 6 Inventory 395 250898.9 351514.6 99105051
> 374.00 2881005
> 7 Returns 395 2967.3 4611.74 1172092
> 10.00 57362.00
>
>
> Since the statistics you request are included in the DEFAULT output
> data set from PROC SUMMARY and NMISS can be easily calculated this is
> another possibility.
>
> proc summary data=test nway;
> var _numeric_;
> output out=stats;
> run;
> proc transpose out=test2;
> by _type_ _freq_;
> id _stat_;
> run;
> data test2;
> set test2;
> nMiss = _freq_ - N;
> run;
> proc print;
> run;
>
>
>
>
> On 7/20/10, Jeff <zhujp98@gmail.com> wrote:
>> I have a datasets with about 200 numeric variables.
>> I want to create a dataset containing Nmiss, N, Max and Min for all
>> variables.
>> Is there a good ways to do that?
>> The resulting dataset should looks like:
>>
>> varname #ofmissing N max min
>> qqq 543 123472 80 0
>> sdd
>> dsdsd
>> ssdsdd
>>
>> Thanks.
>> Jeff
>>
>
|