So I have this sample data format
ID | Block | Value | WANT |
1 | A | -10 | 1 |
1 | A | 0 | 2 |
1 | A | 0.52 | 3 |
1 | A | 18 | 4 |
1 | A | 20 | 5 |
1 | A | 25 | 6 |
1 | b | -19 | 1 |
1 | b | 0.25 | 2 |
1 | b | 0.96 | 3 |
1 | b | 21 | 4 |
1 | b | 32 | 5 |
1 | b | 45 | 6 |
So I want to code a rank based on the values for each ID/block. All patients have 12 records (6 for block A and 6 for block B). So I did the first step where I used proc sort by ID Block and Value. Now I want to create that WANT variable where it indicates the rank within each ID/Block. What is the easiest way to do this?
Thanks!
data want;
by id block;
if first.block then want=1;
else want+1;
run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.