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

 

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;



Hi,

IF Condition with few numeric and character types are to be considered, and out put to be displayed should be a character Value (YES or NO) which is resulting in the following NOTE.
NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column).
70:37
NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column).
70:147 71:83 72:78 72:147
What could be possible solution?
1. Convert the numeric values to character values?
2. Doing #1, is leading to another NOTE which says that the variable is both in character and numeric.
Any suggestions?
Thank you,
 

Regards,
Nasya
1 ACCEPTED SOLUTION

Accepted Solutions
pau13rown
Lapis Lazuli | Level 10

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.

View solution in original post

4 REPLIES 4
pau13rown
Lapis Lazuli | Level 10

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

Nasya
Obsidian | Level 7
Thanks for your response. AVALUE is in numeric only, no conversion is made. Other values are Character in type. The new variable is a character too- displaying output as Yes or No.
Combining Numeric and Character values and displaying output as Character is possible or do we have to convert all the variables to Character?
pau13rown
Lapis Lazuli | Level 10

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.

Nasya
Obsidian | Level 7
Worked. Thanks a lot.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 3425 views
  • 0 likes
  • 2 in conversation