DATA Step, Macro, Functions and more

Character values have been converted to numeric values

Accepted Solution Solved
Reply
New Contributor
Posts: 2
Accepted Solution

Character values have been converted to numeric values

I am using SAS 9.4 and keep getting the following note in my SAS log at various locations

 

NOTE: Character values have been converted to numeric values at the places given by:
(Line)Smiley SadColumn).
22:18

here is an example of code which causes the problem. 

 

 



DATA SET1; /*Format data, create new variables*/
SET DAD_RawFile;
Length MRD_ICD9_3digit $3 SEX_1 $7;
TITLE 'SET 1';

/*Create a CAUSE_ICD9_3digit variable to code for specific causes*/
IF code_indicator = 'ICD9' THEN MRD_ICD9_3digit = substr(MRD,1,3); /*Text variable containing 1st THREE characters of the ‘MRD’ variable*/
ELSE MRD_ICD9_3digit = '';

/*Recode missing rescode as '00000'*/
IF rescode = '' OR rescode = . THEN rescode = 00000;

/*Standardize sex variable*/
IF sex =: 'M' THEN SEX_1 = 'Male';
ELSE IF sex =: 'F' THEN SEX_1 = 'Female';
ELSE IF sex= '' THEN SEX_1 = 'Unknown';
ELSE SEX_1 = 'Error';
RUN;

and in the results viewer i get the following note

11
12   DATA SET1; /*Format data, create new variables*/
13       SET DAD_RawFile;
14       Length MRD_ICD9_3digit $3 SEX_1 $7;
15       TITLE 'SET 1';
16
17   /*Create a CAUSE_ICD9_3digit variable to code for specific causes*/
18       IF code_indicator = 'ICD9' THEN MRD_ICD9_3digit = substr(MRD,1,3); /*Text variable
18 ! containing 1st THREE characters of  the ‘MRD’ variable*/
19           ELSE MRD_ICD9_3digit = '';
20
21   /*Recode missing rescode as '00000'*/
22       IF rescode = '' OR rescode = . THEN rescode = 00000;
23
24   /*Standardize sex variable*/
25       IF sex =: 'M' THEN SEX_1 = 'Male';
26       ELSE IF sex =: 'F' THEN SEX_1 = 'Female';
27       ELSE IF sex= '' THEN SEX_1 = 'Unknown';
28       ELSE SEX_1 = 'Error';
29   RUN;

NOTE: Character values have been converted to numeric values at the places given by:
      (Line):(Column).
      22:18


I was thinking that when i created the new variable as character and defined its length (i.e.

Length MRD_ICD9_3digit $3 SEX_1 $7;

 Then it would end up as character but it seems as though SAS is converting it to numeric and i'm not sure why or how much it is impacting my data set. I'm also not sure how to fix it. 


Accepted Solutions
Solution
‎03-08-2018 09:03 AM
Super User
Posts: 6,632

Re: Character values have been converted to numeric values

You are getting this message because of RESCODE.  You need to refer to it properly.  If it is character, you could code:

 

if rescode = ' ' then rescode = '00000';

 

If it is numeric, the code would be:

 

if rescode = . then rescode = 0;

 

But this beginning is definitely going to force a conversion:

 

if rescode = ' ' or rescode = . then .........

View solution in original post


All Replies
Solution
‎03-08-2018 09:03 AM
Super User
Posts: 6,632

Re: Character values have been converted to numeric values

You are getting this message because of RESCODE.  You need to refer to it properly.  If it is character, you could code:

 

if rescode = ' ' then rescode = '00000';

 

If it is numeric, the code would be:

 

if rescode = . then rescode = 0;

 

But this beginning is definitely going to force a conversion:

 

if rescode = ' ' or rescode = . then .........

New Contributor
Posts: 2

Re: Character values have been converted to numeric values

Posted in reply to Astounding

Thank you for the reply. I was able to correct the problem in the code i shared as well as go through the rest of the code in that file and correct similar errors. I have now run all of the code and it is error free. 

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 243 views
  • 1 like
  • 2 in conversation