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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

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