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

 

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
1 ACCEPTED SOLUTION

Accepted Solutions
desireatem
Pyrite | Level 9

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;

View solution in original post

7 REPLIES 7
novinosrin
Tourmaline | Level 20

Use max function:

 

Max_CIWA=max(of CIWA: );

desireatem
Pyrite | Level 9

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;

desireatem
Pyrite | Level 9

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;

johndschmitz
Calcite | Level 5

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.

Andygray
Quartz | Level 8

@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.

desireatem
Pyrite | Level 9

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

desireatem
Pyrite | Level 9

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. 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2721 views
  • 2 likes
  • 4 in conversation