Get quantified by group in SAS
I have a table like this:
Cluster Age FR
8 70 153
...
I want to get a table: for each cluster and for each age, the average FR in every 10th quantile. It should look like this:
Cluster Age Quantile FR
1 1 10% 12
1 1 20% 14
1 1 30% 16
1 1 40% 18
1 1 50% 20
1 1 60% 22
1 1 70% 24
1 1 80% 26
1 1 90% 28
1 1 100% 30
1 2 10% 13
1 2 20% 15
1 2 30% 17
I have tried doing this with a uniprocessor, but no success ...
proc univariate data=etude.Presta_cluster_panier noprint;
var FR;
output out=pctls pctlpre=P_ pctlpts=0 to 100 by 10;
run;
+3
M Darblade
source
to share
2 answers
This can be accomplished in two steps by using the proc and proc ranks.
proc rank data=etude.Presta_cluster_panier out=outranks groups=10;
var FR;
ranks Quantile;
by Cluster Age;
run;
proc means data=outranks;
var FR;
ways 3;
class Cluster Age Quantile;
output out=outmean;
run;
+2
JJFord3
source
to share
You will need to get your quartiles by cluster and age first. Then try again with your base dataset, assign groups based on your quartiles, and finally calculate the average cluster age and quartile.
This cannot be done in one step.
+1
M4hd1
source
to share