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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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