/ Published in: SAS
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
/* original data set */
data firm; input category size @@;
datalines;
1 93458934 1 8467489 1 8679 2 56757 3 57850
1 456794 2 697058 2 59876 3 687957 3 698879
3 598679 1 8756356 1 356396 1 65365 2 56385
2 4686 2 469674967 2 49679674 3 4686 3 47696
3 76946794 3 64868
;
/* sort by category and then by size within each category in descending order */
proc sort data=firm;
by category DESCENDING size;
run;
/* create rank variable within each category */
data firm1; set firm;
by category;
rank+1;
if first.category then rank=1;
run;
/* data set that contains 5 biggest firms within each category */
data firm2; set firm1(where=(rank<6));
run;
URL: http://support.sas.com/forums/message.jspa?messageID=21083#21083
Comments
 Subscribe to comments
                    Subscribe to comments
                
                