Dear Freinds,
need yout help in this .
data test;
input ANR_Q1 ANR_Q2 ANR_Q3;
datalines;
1 2 5
9 6 3
8 9 3
5 6 7
4 6 3
;RUN;
want to output like this
ANR_Q1 ANR_Q2 ANR_Q3 Base;
1 2 5 5
9 6 3 9
8 9 3 9
5 6 7 7
4 6 3 6
data want;
set test;
array have(*) ANR_Q1 ANR_Q2 ANR_Q3;
array temp(3);
do i=1 to dim(have);
temp(i)=have(i);
end;
call sortn(of temp:);
Base=temp3;
drop i temp:;
run;
data want;
set test;
array have(*) ANR_Q1 ANR_Q2 ANR_Q3;
array temp(3);
do i=1 to dim(have);
temp(i)=have(i);
end;
call sortn(of temp:);
Base=temp3;
drop i temp:;
run;
thanx a lot
simply take a maximum:
data max_base;
set test;
Base = max(of ANR_Q1 - ANR_Q3);
run;
not working
Your reply to @stataddict is less thank helpful. Since you simply want to find the max of a "list of variables" I believe that is correct. I'm guessing you left out OF before the variable list.
you are correct it was my mistake
@stataddict my Apologies i think i left of in the code
No problem
Simply use the following code :
DATA TEST;
INPUT ANR_Q1 ANR_Q2 ANR_Q3;
BASE = MAX (OF ANR_Q1 - ANR_Q3);
DATALINES;
1 2 5
9 6 3
8 9 3
5 6 7
4 6 3
;
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.