want to create a max base

Accepted Solution Solved
Reply
Contributor
Posts: 74
Accepted Solution

want to create a max base

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


Accepted Solutions
Solution
‎02-27-2014 05:29 AM
Occasional Contributor
Posts: 12

Re: want to create a max base

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 tempSmiley Happy;

     Base=temp3;

     drop i temp:;

run;

View solution in original post


All Replies
Solution
‎02-27-2014 05:29 AM
Occasional Contributor
Posts: 12

Re: want to create a max base

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 tempSmiley Happy;

     Base=temp3;

     drop i temp:;

run;

Contributor
Posts: 74

Re: want to create a max base

thanx a lot

Occasional Contributor
Posts: 14

Re: want to create a max base

simply take a maximum:

data max_base;

set test;

Base = max(of ANR_Q1 - ANR_Q3);

run;

Contributor
Posts: 74

Re: want to create a max base

not working

Respected Advisor
Posts: 3,777

Re: want to create a max base

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.

Contributor
Posts: 74

Re: want to create a max base

you are correct it was my mistake

Contributor
Posts: 74

Re: want to create a max base

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

Occasional Contributor
Posts: 14

Re: want to create a max base

No problem Smiley Happy

Occasional Contributor
Posts: 8

Re: want to create a max base

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

;

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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