Dear SAS Community,
This is probably an easy question, however, I have trouble making it work. I just want to find out either a maximum or minimum number from two numbers that have unique values. For an example, I get errors when writing below:
data Test;
q1=5;
q2=10;
z=Largest(q1, q2);
run;
Thank you for your help!
Are you expecting to find the lowest value in the row or in the column?
If row the command can be MIN/MAX as in your subject line.
You can use the LARGEST function but the first parameter is what order your looking for, 1 is the maximum and 2 is the second highest. If you only have 2 values then that would correspond to max/min.
x = min(q1, q2);
y = max(q1, q2);
x_large = Largest(1, q1, q2);
y_large = Largest(2, q1, q2);
See the doc for LARGEST()
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002154862.htm
LARGEST (k, value-1<, value-2 ...>)
Arguments
k
is a numeric constant, variable, or expression that specifies which value to return.
value
specifies the value of a numeric constant, variable, or expression to be processed.
data Test;
q1=5;
q2=10;
z=Largest(1,q1, q2);
run;
Are you expecting to find the lowest value in the row or in the column?
If row the command can be MIN/MAX as in your subject line.
You can use the LARGEST function but the first parameter is what order your looking for, 1 is the maximum and 2 is the second highest. If you only have 2 values then that would correspond to max/min.
x = min(q1, q2);
y = max(q1, q2);
x_large = Largest(1, q1, q2);
y_large = Largest(2, q1, q2);
See the doc for LARGEST()
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002154862.htm
LARGEST (k, value-1<, value-2 ...>)
Arguments
k
is a numeric constant, variable, or expression that specifies which value to return.
value
specifies the value of a numeric constant, variable, or expression to be processed.
Thank you, Reeza!
I understand how the formula works now 🙂
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.