BookmarkSubscribeRSS Feed
SASPhile
Quartz | Level 8
data _null_;
set x;
if (input(substr(dat,1,2),8.) > 12
or
input(substr(dat,4,2),8.)> 31
)
then error = 'Y';
if error = 'Y' then abort;
put 'ERROR:Error in the date field.Correct the date field in the source data';
run;

I forced values where month is greater than 12 and day is greater than 31.The process did not stop (abort).It processed further.
1 REPLY 1
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
First, I encourage you to enhance your data validation by converting the character date-string to a SAS numeric DATE variable where SAS will validate the data more accurately during the INPUT function processing, the test the _ERROR_ variable for non-zero before you do some exception action.

For your particular post/query, you will want to read the specific OS companion guide about how ABORT works in your particular OS, also considering such OPTIONS as ERRORABEND/NOERRORABEND.

Scott Barry
SBBWorks, Inc.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 591 views
  • 0 likes
  • 2 in conversation