## To return the maximun

Solved
Highlighted
Super Contributor
Posts: 307

# To return the maximun

[ Edited ]

Hello I wish to to return  the maximum of , CIWA_Score1,  CIWA_Score2,  CIWA_Score3,  CIWA_Score4 as "Max_CIWA".

My data has _1_CIWA_Score,  _2_CIWA_Score,  _3_CIWA_Score,  _4_CIWA_Score. Can any one help?

 _1_CIWA_Score _2_CIWA_Score _3_CIWA_Score _4_CIWA_Score4 Max_CIWA . . . . . . . . . . 4 . . . 4 7 4 1 6 7 1 0 0 5 5 1 0 . . 1 4 17 7 5 17 3 4 4 . 4 2 . . . 2 4 0 . . 4 1 0 0 0 1

Accepted Solutions
Solution
‎10-07-2017 10:40 AM
Super Contributor
Posts: 307

## Re: To return the maximun

works!!!!!!!!!!!!!!!!!

690 data BH_New;
1691 set BH_New;
1692 CIWA_Score=Max(of _1_CIWA_Score, _2_CIWA_Score, _3_CIWA_Score, _4_CIWA_Score);
1693 run;

All Replies
PROC Star
Posts: 829

## Re: To return the maximun

[ Edited ]

Use max function:

Max_CIWA=max(of CIWA: );

Super Contributor
Posts: 307

## Re: To return the maximun

665 data BH_New;
1666 set BH_New;
1667 CIWA_Score=max(of _1_CIWA_Score -_4_CIWA_Score);
---
71
ERROR: Missing numeric suffix on a numbered variable list (_1_CIWA_Score-_4_CIWA_Score).
ERROR 71-185: The MAX function call does not have enough arguments.

1668 run;

Solution
‎10-07-2017 10:40 AM
Super Contributor
Posts: 307

## Re: To return the maximun

works!!!!!!!!!!!!!!!!!

690 data BH_New;
1691 set BH_New;
1692 CIWA_Score=Max(of _1_CIWA_Score, _2_CIWA_Score, _3_CIWA_Score, _4_CIWA_Score);
1693 run;

Senior User
Posts: 1

## Re: To return the maximun

I believe your challenge here is related to the variable naming convention.  The '-' is used when a numeric indicator is at the end of a variable name (for example x1,x2,x3,x4), but not when it is internale to the name (x1_dat, x2_dat, x3_dat).  What you can do, assuming that the variables are in this order on the program data vector (PDV) is use a double dash '--'.

In your case, _1_CIWA_Score --_4_CIWA_Score.  This will include any variable in the DATA step created between the first introduction of _1_CIWA_Score  and the  first introduction of _4_CIWA_Score.  If you view the DATA set and these variable appear together as a group with _1_CIWA_Score appearing first and _4_CIWA_Score appearing as the last, you will be fine.

Hope it helps.

Contributor
Posts: 59

## Re: To return the maximun

@desireatem  I think it is unethical to mark your own answers as correct after seeking help on the forum and having got couple of suggestions. That's poor sport and so unprofessional.

Super Contributor
Posts: 307

## Re: To return the maximun

You are right. But some1 who is not registered corrected it and I paste it.

Super Contributor
Posts: 307

## Re: To return the maximun

[ Edited ]

so if I found the solution I shouldn't paste it. That is not what I was taught.  sorry after a second thought I disagree with you Andyx.

☑ This topic is solved.