简体   繁体   中英

SAS - percentile from row

I have a dataset with one base variable and 1000 generated. The base variable is ps_a_pc, the scenarios are called ps_a_var1...ps_a_var1000.

The dataset is as follows:

 ps_a_pc ps_a_var1 .... ps_a_var1000
    0       1      ....    5
    3       6      ....   14

Now I would like to calculate for each row its minimal value, maximal value and percentiles (20%,40%,60%,80%).

It is easy to get maximal and minimal value:

data MinMaxRows;
     set mydata.tot_i;
array x [1000] PS_a_var1-PS_a_var1000;
min = min(of x[*],ps_a_pc);
max = max(of x[*],ps_a_pc);
run;

but is there any simple way how to get percentiles for each row ? The only solution coming to my mind is to transpose the dataset and calculate it using univariate function.

Thank you for any suggestion.

You can use the PCTL function.

data want;
    set have;
    pct80 = pctl(80, of ps_a_var1-ps_a_var1000);
run;

Obviously, adjust the '80' value as required for the other percentiles.

Jiri:

Look at the PCTL() function .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM