CODE:
data trial; /*name of the new dataset*/ attrib new length=$4; /*name of the variable to which calculated value is assigned*/ set database; /*original dataset*/ by SUBJECT; /*sorting by SUBJECT, which is UNIQUE and with no duplicates*/ /*Calculating the new variable by using the following condition*/ if (upcase (AUNIT) eq 'U/L' AND upcase (AVALUE) > 2000) or (upcase (BVALUE) eq 'BILIRUBIN LEVEL' AND upcase (ASUNIT) eq 'MG/DL' AND upcase (AVALUE) > '10') or (upcase (GRAFT) eq 'Yes') then new="Yes"; else new="No"; run; Proc sort data=trial; by SUBJECT; run;
if avalue is numeric why do you have: upcase (AVALUE) > '10'. Note that this is inconsistent with this other piece of code where there are no quote marks: upcase (AVALUE) > 2000. First remove the use of "upcase", if it's numeric you shouldn't be using this. And remove the quote marks in the first bit of code.
to make the note go away, treat the char variable as char and the numeric variable as numeric. You just need to double check what your variables are and then treat them accordingly. There is certainly an issue with this bit "upcase (AVALUE) > 2000", because you are saying avalue is char but treating it as numeric. First convert it to numeric, as you say
if avalue is numeric why do you have: upcase (AVALUE) > '10'. Note that this is inconsistent with this other piece of code where there are no quote marks: upcase (AVALUE) > 2000. First remove the use of "upcase", if it's numeric you shouldn't be using this. And remove the quote marks in the first bit of code.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.