BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
TarunKumar
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
Xianhua_zeng
Fluorite | Level 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;

View solution in original post

9 REPLIES 9
Xianhua_zeng
Fluorite | Level 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;

TarunKumar
Pyrite | Level 9

thanx a lot

stataddict
Calcite | Level 5

simply take a maximum:

data max_base;

set test;

Base = max(of ANR_Q1 - ANR_Q3);

run;

TarunKumar
Pyrite | Level 9

not working

data_null__
Jade | Level 19

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.

TarunKumar
Pyrite | Level 9

you are correct it was my mistake

TarunKumar
Pyrite | Level 9

@stataddict my Apologies i think i left of in the code

stataddict
Calcite | Level 5

No problem Smiley Happy

Trancho
Calcite | Level 5

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

;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1247 views
  • 1 like
  • 5 in conversation