DATA Step, Macro, Functions and more

identify which observation has a character value and generating conversion note

Accepted Solution Solved
Reply
Regular Contributor
Posts: 180
Accepted Solution

identify which observation has a character value and generating conversion note

[ Edited ]

Hi,

 

I am doing a char to numeric conversion, but I am getting one note in my log that says:

 

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

 

I don't have this many lines or columns in my data set.  I also don't see any character values that would generate this note.  I did a proc freq on all the variables I am converting.  Is there any way to specifically identify which value this is pointing to?  I have no idea what the 6232:23 is (i have 3504 rows and 14 columns).  I know it's not a big deal, but I can't have any conversion notes in my log.

 

Here is some of code:

 

length results $100.;
format range $4.;
siresult1=input(siresult,best.);
SINORMLO1=input(SINORMLO,best.);
SINORMHI1=input(SINORMHI,best.);
if siresult1^=. then do;
if siresult1< SINORMLO1 then Range='L';
if siresult1>SINORMHI1 then Range='H';
if SINORMLO1<SIRESULT1<SINORMHI1 then Range='';
results=catx(", ",put(siresult1,8.1), range);
end;
else if siresult1='' then do;
results='';

 

Thank you!


Accepted Solutions
Solution
‎11-16-2017 06:27 PM
Super User
Posts: 22,874

Re: identify which observation has a character value and generating conversion note

The line numbers refer to the numbers in the log. 

CHECK YOUR LOG. And post it.

View solution in original post


All Replies
Solution
‎11-16-2017 06:27 PM
Super User
Posts: 22,874

Re: identify which observation has a character value and generating conversion note

The line numbers refer to the numbers in the log. 

CHECK YOUR LOG. And post it.

Regular Contributor
Posts: 180

Re: identify which observation has a character value and generating conversion note

Found it! Thank you.
PROC Star
Posts: 2,231

Re: identify which observation has a character value and generating conversion note

The numbers are the position in the log.

Here line #27 column # 5.

 

25 
26 data T;
27 A='1'+1;
28 run;

NOTE: Character values have been converted to numeric values at the places given by: (Line)Smiley SadColumn).
27:5 
NOTE: The data set WORK.T has 1 observations and 1 variables.
NOTE: DATA statement used (Total process time):

 

Super User
Posts: 13,084

Re: identify which observation has a character value and generating conversion note

In your code snippet:

if siresult1^=. then do;  <= siresult is numeric
 if siresult1< SINORMLO1 then Range='L';
 if siresult1>SINORMHI1 then Range='H';
 if SINORMLO1<SIRESULT1<SINORMHI1 then Range='';
 results=catx(", ",put(siresult1,8.1), range);
 end;
 else if siresult1='' then do;  <= here you are treating siresult as character

Us the function MISSING:

 

else if missing(siresult) then do ...

OR compare to the missing value

else if sirresult = . then do

 

Use of missing is a better option as that is one of the functions that works with both numeric and character values. Also it makes the code a bit easier to understand.

☑ This topic is solved.

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

Discussion stats
  • 4 replies
  • 129 views
  • 0 likes
  • 4 in conversation