Hello,
I have four variables A, B, C and D. For each row these variables have integer values.
I would like to know how to get the value of the highest variable between the 4. FOr example:
A B C D
12 11 18 7
The result should be 18.
I want to do this with proc sql.
Thanks for help.
Like this?
data have;
input A B C D;
datalines;
12
11
18
7
;
proc sql;
create table want as
select *
,max(A,B,C,D) as highest_value
from have;
quit;
With your data:
data want; a=12; b=11; c=18; d=7; max=max(a,b,c,d); /* or */ mx=max(of _numeric_); run;
The second will take all numeric variables.
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 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.