Hi there, I'm working on a data set with a variable that is ranked according to some criteria, and i'm changing this criteria and comparing the new ranking. So I got a table with the variable being sorted, and its position according to three different rankings. Something like: data have;
infile datalines;
input OBS$ Rank_1$ Rank_2$ Rank_3$;
datalines;
A 1 1 1
B 1 2 1
C 2 2 3
D 4 5 2
E 6 2 8
F 2 7 4
;
run; So, A is first position in all three rankings, B is first in Rankings 1 and 3, but second in Ranking 2, etc. What I want is to count how many items are at each positions per ranking. It would look something like: data want;
infile datalines;
input Position$ n_Rank_1$ n_Rank_2$ n_Rank_3$;
datalines;
1 2 1 2
2 2 3 1
3 0 0 1
4 1 0 1
5 0 1 0
6 1 0 0
7 0 1 0
8 0 0 1
;
run; So Ranking 1 has 2 items at first and second positions, 1 item at fourth and sixth positions. Ranking 2 has 1 at first, 3 at second and etc. I sure managed to do that separately, one ranking at a time, using SQL "select rank, count(rank)". But I would like to do that just once and couldn't find a solution on my own. And also, using SQL, it only displays the positions that occurs in the table. Meaning that the first one shows only 1st, 2nd, 4th and 6th positions, but I want every position, with the zeros. Any thoughts?
... View more