Programming the statistical procedures from SAS

double sort proc rank

Reply
Occasional Contributor
Posts: 11

double sort proc rank

[ Edited ]

Hello

I would like to double sort the firms based on their size (TNA) and their concentration. Therefore, first, I need to sort the firms into terciles based on their size  and then sort them based on their concentration. I need then to estimate for each generated portfolio its returns and calculate the difference between tercile 3 and tercile 1

 

The aim is to  obtain the following :

 

concentration:                            size :  

                                    1-small         2         3-large

1-diversified

 

2-

 

3- concentrated

 

tercile 3- tercile1             x             x           x

 

 I would like to know if my sas code is correct and to know how can I calculate tercile3-tercile1 and where to insert that in my sas code.Thank youu in advance

proc rank data=doublesort groups=3 out=ranked;
by date;
   var TNA;
   ranks GROUP_1;
run;
proc rank data=ranked groups=3 out=rankedfinal;
by date
   var Concentration;
   ranks GROUP_2;
run;

proc sort data=rankedfinal; by  date GROUP_2 GROUP_1 ;run;

PROC UNIVARIATE DATA= rankedfinal noprint;
var return;
by date GROUP_2 GROUP_1 ;
output out= ga3 mean=MOYENNE;
run;

proc sort data=ga3; by GROUP_2 GROUP_1;run;
proc means data = ga3 noprint ;
  by GROUP_2 GROUP_1 ;
    var moyenne;
    output out = rankedfinal1 mean= ewret;
run;

 

 

Ask a Question
Discussion stats
  • 0 replies
  • 138 views
  • 0 likes
  • 1 in conversation