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.
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.