while read the data if i have an invalid date (like 31st Feb). How to identify this?
SAS will flag invalid data (which can't be converted with the informat used) with a NOTE in the log, and set the automatic variable _ERROR_.
The value will be set to missing.
this paper has what I believe you are asking for.
http://support.sas.com/resources/papers/proceedings13/122-2013.pdf
Hello @vThanu,
Here's a short example:
data test;
input d date9.;
format d date9.;
cards;
31DEC2018
.
31FEB2019
;
Thanks to the date informat used, messages in the log notify you about the invalid date in the third raw data record, but not about the missing date in the second:
NOTE: Invalid data for d in line 221 1-9. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 221 31FEB2019 d=. _ERROR_=1 _N_=3
Both will normally appear as numeric missing values in dataset TEST (displayed as a period).
You can modify this behavior in different ways. For example, you can
options invaliddata='X';
data test;
input c $9. @1 d ??date9.;
format d date9.;
cards;
31DEC2018
.
31FEB2019
;
Now the invalid date is represented by the special missing value .X, the log is clean and character variable C is available for investigations.
Please see section How Invalid Data Is Handled of the INPUT statement documentation for more information.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.