BookmarkSubscribeRSS Feed
sasphd
Lapis Lazuli | Level 10

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_NOVarNameQuantileEstimate
1X100% Max2,04178
1X99%1,855866
1X95%1,601379
1X90%1,455169
1X75% Q31,24162
1X50% Median0,976555
1X25% Q10,75844
1X10%0,549392
1X5%0,47554
1X1%0,132898
1X0% Min-0,02425
2X100% Max2,311919
2X99%1,72241
2X95%1,504458
2X90%1,361372
2X75% Q31,176674
2X50% Median0,986445
2X25% Q10,804874
2X10%0,65509
2X5%0,558072
2X1%0,244873
2X0% Min-0,21428


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

VarNameQuantileEstimate
X100% Max
X99%
X95%
X90%
X75% Q3
X50% Median
X25% Q1
X10%
X5%
X1%
X0% Min
7 REPLIES 7
Reeza
Super User

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?

sasphd
Lapis Lazuli | Level 10

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?

Reeza
Super User

Using the quantiles output?

Proc means data=quantiles;

class quantile;

var estimate;

output out=want mean=estimate;

run;

sasphd
Lapis Lazuli | Level 10

when I run your program I obtain

Quantile_TYPE__FREQ_estimate
0306461,023439
0% Min127860,084684
1%127860,26137
10%127860,612162
100% Max127862,064825
25% Q1127860,791249
5%127860,500818
50% Median127860,983584
75% Q3127861,18967
90%127861,403732
95%127861,537687
99%127861,828053

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

Reeza
Super User

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;

sasphd
Lapis Lazuli | Level 10

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;

Reeza
Super User

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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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