11-07-2014 12:19 PM
NOTDIGIT works with character values. And all it would do was to tell the first position of a non-digit character in the variable.
If the data is numeric then it won't help at all. Can you provide some examples of the invalid data and the desired correction and rules for correction?
11-07-2014 12:43 PM
Wow, thanks for that since I reached the same conclusion EARLY on. Regardless, here it is. I am using a LARGE data set, and the error msg:
NOTE: Invalid argument to function INPUT at line 21 column 48.
I need to id the obs where this is happening. If I count the lines in code beg with my options; I find a var... Now what run a freq with that var...? This is not my code (inherited). Thanks!
11-07-2014 01:59 PM
This was actually the first note I was referencing when I began here, however it disappeared and since the error is data related to another program (again, inherited) I included a corresponding error msg. Complicated but not really.
NOTE: Invalid numeric data, temp_OTHER_WORK_ACTIVITIES='K' , at line 22 column 173.
11-07-2014 03:56 PM
I have to assume now that since there is an error with INPUT function that the variable is Character (not numeric as stated previously).
If the values do not contain decimals or commas a start is:
If notdigit(variable)>0 then do;
If I were building a data set with such an issue I might be tempted to start with:
set have ;
if variable=.; /*This variable being the one that is going to be missing when the INPUT function had invalid input values.*/
If I have a suspicion which variables are possible culprits and the number of variables is significant I might also reduce this examination set with a Keep statement.
That would let me look for patterns within the data that yield that result. RecordNumber will the observation number(s) with the problem data.
I've done enough code archeology to sympathize with inherited code and changed data inputs. But when I see "numeric data" in a question that is what I can address, not "character data that is masquerading as numeric".
11-10-2014 03:30 PM
Getting acquainted with administrative, messy, large data prevents a timely response. The Keep stmt was a no-brainer, so thanks for the reminder and the RecordNumber = _n_ seems to be returning promising results. Thank you!
I'll be back on the input errors shortly after I try some of this there as well. Thank you!!!
11-12-2014 10:58 AM
I thought I successfully removed values for 3 vars replacing '.' with '0' (there were many) however what is required is to convert values that are not numeric, e.g. "K', for obs for these 3 vars. Something like, RecordNumber = _n_; if var = notdigit;
11-12-2014 11:02 AM
What I don't understand is why creator used *1 for conversion from char to numeric, rather than input function. Because they are savy progammer, there is likely a good reason. Thinking I might do so for just those 3 vars. I do not want to rewrite all the code (very long).
11-12-2014 12:30 PM
Perhaps. SAS is supposed to convert non-numerics to '.' on a conversion, but this did not happen. I'm tired of this problem, since I have a much bigger sas problem awaiting.
11-14-2014 03:31 PM
NOTE: Invalid argument to function INPUT at line 3403 column 17. Macro (inherited) code with many renames, do loops and character to numeric conversions. Do not know where to start. Pardon my frustration. Any help is appreciated.
11-14-2014 03:45 PM
Usually the invalid argument note includes a dump of values currently assigned to variables and an _N_ = ;
The _N_ tells you which record(s) in the input data have the problem. If the code is buried in a macro you may need to turn options MPRINT and/or SOURCE on to get a better idea of which line 3403 may be. Column 17 on that line is likely to have the function called that is having an issue with the value of a variable. If you can identify that line and the function then look in the data dump for the variables used. The problem value is often pretty obvious, missing, character when should be numeric and can't be cast as numeric are likely culprits. Hard to diagnose without data/log/code. You may want to start a new thread.
11-14-2014 04:01 PM
Thank you. I started a new thread, although my help here seems more powerful. But I take advice. I am going back to try the MPRINT and Source. Yes the dump is there, and I believe you when you write is should be pretty obvious. My problem is I am learning this messy data still. One of my problems is the code take almost 2 hours to run, so figuring out how to triage without waiting 2+ hours a run would be smart. Thank you.
11-07-2014 04:21 PM
You could probably use the ?? modifier to suppress the automatic error message and produce your own message.
data check ;
input str $12. ;
num = input(str,?? 12.);
if missing(num) and not missing(str) then put
'WARNING: Invalid numeric value. ' _n_ = str= :$quote. ;
What is this?