Hi,
I have a dataset sorted by patients; e.g. 2 observations/lines (of data) for patient 1, 4 lines for patient 2 and so on. I have a variable (we call it "LINES") counting the lines for each patient (1, 2, 3, 4 and so on).
I need to create a new variable with data from the the last line for each patient, in other words the highest value of the variable "LINES" (sorted by patients).
How do I create a syntax with "highest value" (it should bed sorted by patients already) of a variable?
/Mette
proc sort data=have;
by patient lines;
run;
data want;
set have;
by patient;
if last.patient;
run;
Hello,
Instead of describing in words your situation it will be useful to post an example of your data.
It is easier to look at data you have - data you want than reading a description.
proc sort data=have;
by patient lines;
run;
data want;
set have;
by patient;
if last.patient;
run;
Thanks a lot KurtBremser. It was exactly the commando I needed. 🙂
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.