From: Xin on
I need to compare 5 variables' values p1 -p5 , and create a new
variable return to the largest value of p1 - p5,

Is there any simply way ( sas funtions..) to get this rather than
writing a loop compare one by one?

Your help will be much appreciated!

-Xin
From: PJ on
Xin, are you looking for this shown below?

data test;
input v1-v5;
cards;
1 2 3 4 5
21 11 10 22 20
;

data test1;
set test;
newvar = max(of v1 -v5);
run;
From: Xin on
On Mar 2, 11:17 am, PJ <luxuem...(a)yahoo.com> wrote:
> Xin, are you looking for this shown below?
>
> data test;
> input v1-v5;
> cards;
> 1 2 3 4 5
> 21 11 10 22 20
> ;
>
> data test1;
>    set test;
>    newvar = max(of v1 -v5);
> run;

Yep, thank you so much!

The other function ordinal can return kth smallest value of the v1-v5,
I just found it, that make my program even more efficient!

Again, thank you very much for your help!

-Xin