Reputation: 159
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.
Upvotes: 2
Views: 1361
Reputation: 386
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.
Upvotes: 1