Magnus
Magnus

Reputation: 760

How do I decipher SAS line and column references?

I recently used a modified version of this code in order to convert a couple of hundred character variables to numeric. The code executes, but I get a load of notes like these ones:

NOTE: Invalid argument to function INPUT at line 185 column 13.
NOTE: Invalid argument to function INPUT at line 185 column 13.
NOTE: Invalid argument to function INPUT at line 185 column 13

I would like to diagnos this but I don't really know where to begin. The messages appear after the following step has been executed:

data datamodell_index;                                               
   set datamodell_index;                                                 
   array ch(*) $ &c_list;                                    
   array nu(*) &n_list;                                      
   do i = 1 to dim(ch);                                      
      nu(i)=input(ch(i),8.);                                  
   end;                                                      
   drop i &c_list;                                           
   rename &renam_list;                                                                                      
run; 

What lines and columns is the program even referring to? The ones in the SQL table? The ones in the raw data? The ones in the actual code generated by the macro variables?

How do I see what the program sees, so I can get a sense of what's the problem?

Upvotes: 0

Views: 897

Answers (4)

PeterClemmensen
PeterClemmensen

Reputation: 4937

The line and column are the lines and columns in your log where the problem is.

As a first, try to use a Put Statement and write the i'th iteration to the log. When the log gives you an not, inspect the i'th element of the ch array and see what is wrong from there.

Upvotes: 2

Gaadek
Gaadek

Reputation: 159

The note is pretty clear about the root cause: NOTE: Invalid argument to function INPUT at line 185 column 13.

The issue is probably generated by the statement nu(i)=input(ch(i),8.); where the content of your ch array at index i does not contain a value that can be converted to a numeric.

I think you need to check why you have invalid value, one option could be to amend the code to output an informative note about the values that cause that note:

data datamodell_index;
   set datamodell_index;
   array ch(*) $ &c_list;
   array nu(*) &n_list;
   do i = 1 to dim(ch);
      nu(i)=input(ch(i),8.);

      *-- Displays the value that cannot be converted to numeric in the SAS log --*;
      if missing(nu(i)) and not missing(ch(i)) then put "NOTE: cannot convert value " ch(i) "to numeric";
   end;
   drop i &c_list;
   rename &renam_list;
run; 

Upvotes: 1

Tom
Tom

Reputation: 51611

The line and column refer the the line number printed in the SAS log for the code. The column is the place on the line where SAS was able to detect the error (might be different than the actual cause of the error).

Example:

1126  data test;
1127    string='hello';
1128    number = input(string,8.);
1129  run;

NOTE: Invalid argument to function INPUT at line 1128 column 12.
string=hello number=. _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
      missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      1 at 1128:12
NOTE: The data set WORK.TEST has 1 observations and 2 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds

So line number 1128 is the one with the INPUT() function call. The 12th character on that line is the start of the INPUT() function call.

Bascially you have some character variables that cannot be converted to a number using the 8. informat.

Notice how it also listed the values of all of the variables at the time the INPUT() function generated the error. In my simple example it is easy to see that there is no way to convert hello to a number. In your case since you are using array references you will need to check the value of the index variable to see which of the many character variable values you should look at to see what particular string it is having trouble converting.

PS The INPUT() function does not care if the width used on the informat is larger then the length of the character variable. So use the maximum width the informat allows. In the case of the normal numeric informat the maximum width it supports is 32. So use informat of 32. instead of 8. in the INPUT() function call.

Upvotes: 2

Magnus
Magnus

Reputation: 760

So apparantly lines and columns in this case "macro block" and to the "character number" in question.

A more in-deph explanation can be found here:

https://www.lexjansen.com/wuss/2006/data_presentation_and_business_intelligence/DPR-Sherman.pdf

Upvotes: -1

Related Questions