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 |
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;
Use max function:
Max_CIWA=max(of CIWA: );
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;
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;
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.
@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.
You are right. But some1 who is not registered corrected it and I paste it.
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.
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!
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.
Ready to level-up your skills? Choose your own adventure.