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):(Column).
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.
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 .........
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 .........
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.
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.