proc univariate

Frequent Contributor
Posts: 126

proc univariate

hello,

I use proc univariate and i generate output files (quantiles and mean).

proc univariate data=bb.mdist;

var X;

by rank_no;

ods output Quantiles=quantiles;

run;

The file quantiles is like :

 Rank_NO VarName Quantile Estimate 1 X 100% Max 2,04178 1 X 99% 1,855866 1 X 95% 1,601379 1 X 90% 1,455169 1 X 75% Q3 1,24162 1 X 50% Median 0,976555 1 X 25% Q1 0,75844 1 X 10% 0,549392 1 X 5% 0,47554 1 X 1% 0,132898 1 X 0% Min -0,02425 2 X 100% Max 2,311919 2 X 99% 1,72241 2 X 95% 1,504458 2 X 90% 1,361372 2 X 75% Q3 1,176674 2 X 50% Median 0,986445 2 X 25% Q1 0,804874 2 X 10% 0,65509 2 X 5% 0,558072 2 X 1% 0,244873 2 X 0% Min -0,21428

Then, I want to perform the mean quantile by quantile so I obtain a table like this

 VarName Quantile Estimate X 100% Max X 99% X 95% X 90% X 75% Q3 X 50% Median X 25% Q1 X 10% X 5% X 1% X 0% Min
Super User
Posts: 23,771

Re: proc univariate

Do you want to run the results through a proc means to get the average max for example or do you want to have the results for the full dataset, i.e. not by Rank_no, which would mean running proc univariate once more without by statement?

Frequent Contributor
Posts: 126

Re: proc univariate

Yes I want to have the average of each quantile. Like the value of max for all rank_no. the problem here is that how i can apply proc means?

Super User
Posts: 23,771

Re: proc univariate

Using the quantiles output?

Proc means data=quantiles;

class quantile;

var estimate;

output out=want mean=estimate;

run;

Frequent Contributor
Posts: 126

Re: proc univariate

when I run your program I obtain

 Quantile _TYPE_ _FREQ_ estimate 0 30646 1,023439 0% Min 1 2786 0,084684 1% 1 2786 0,26137 10% 1 2786 0,612162 100% Max 1 2786 2,064825 25% Q1 1 2786 0,791249 5% 1 2786 0,500818 50% Median 1 2786 0,983584 75% Q3 1 2786 1,18967 90% 1 2786 1,403732 95% 1 2786 1,537687 99% 1 2786 1,828053

Why the percentiles are not ordred. and What is the first line means

Super User
Posts: 23,771

Re: proc univariate

Quantile looks to be a text variable so its sorted alphabetically.

The first line is the average of all the values, note _TYPE_=0

You can get numeric quantiles by manually calculating the percentiles in proc univariate using pctpts, though you may need to transpose the results then.

proc univariate data=bb.mdist;

var X;

by rank_no;

ods output pctlpts=0 to 100 by 5 pctlpre=P_;

run;

Frequent Contributor
Posts: 126

Re: proc univariate

i got this error

2816  proc univariate data=bb.mdist;

2817  var m_max_mret;

2818  by rank_no;

2819  ods output pctlpts=0 to 100 by 5 pctlpre=P_;

-

22

76

ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string.

ERROR 76-322: Syntax error, statement will be ignored.

2820  run;

Super User
Posts: 23,771

Re: proc univariate

my bad, that should be output out=DATASET.

You can explicitly list your percentiles if you want exactly the percentiles from the quantiles table.

proc univariate data=bb.mdist;

var X;

by rank_no;

output out=want pctlpts=0 to 100 by 5 pctlpre=P_;

run;

Discussion stats
• 7 replies
• 413 views
• 3 likes
• 2 in conversation