I have dataset like this
data have;
input subjid value;
format subjid z3.;
cards;
001 -4
005 -4
003 30
002 -4
004 -4
006 26
007 6
;
run;
step1: Sorting by ascending and give rank number.
step2:subject with the same vaule are given the average of the rankings;
For step 2 : I have no idea how to output average of the rankings;
Please kindly help;
Final output result i want like this ,
I hope that helps you understand my question
data want;
input subjid value rank;
format subjid z3.;
cards;
001 -4 5.5
005 -4 5.5
003 30 1
002 -4 5.5
004 -4 5.5
006 26 2
007 6 3
;
run;
Proc Rank to the rescue:
data have;
input subjid value;
format subjid z3.;
cards;
001 -4
005 -4
003 30
002 -4
004 -4
006 26
007 6
;
run;
proc rank data = have out = want DESCENDING;
var value;
ranks rank;
run;
B
Proc Rank to the rescue:
data have;
input subjid value;
format subjid z3.;
cards;
001 -4
005 -4
003 30
002 -4
004 -4
006 26
007 6
;
run;
proc rank data = have out = want DESCENDING;
var value;
ranks rank;
run;
B
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.