BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
DDutton
Fluorite | Level 6

Hi Data Step Programmers,

I'm trying to do something which I thought could be solved with a simple function call, but I've searched and searched for a function to do this and have come up empty so far.

 

I have 3 numeric variables: year, month and day

I want to determine that they correspond to a valid date, without getting notes such as the below. I need something like MVALID or NVALID, but for a date, not a member name or variable name.  Surely this has been solved before!  Ideas?

 

I'm running SAS 9.4 M3, OS WX64_SV, .

 

62 data _null_;
63 year=2012;
64 month=2;
65 day=30;
66 date=mdy(month,day,year);
67 date2=input(put(year,4.)||put(month,z2.)||put(day,z2.),yymmdd8.);
68 put date=date7. date2=date7.;
69 run;

NOTE: Invalid argument to function MDY(2,30,2012) at line 66 column 7.
NOTE: Invalid argument to function INPUT at line 67 column 8.
date=. date2=.
year=2012 month=2 day=30 date=. date2=. _ERROR_=1 _N_=1
NOTE: Mathematical operations could not be performed at the following places. The results of the operations have been set to
missing values.
Each place is given by: (Number of times) at (Line):(Column).
1 at 66:7 1 at 67:8

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

Using the DATE2= variation, see if you can suppress messages by adding ?? in the right place:

 

date2=input(put(year,4.)||put(month,z2.)||put(day,z2.), ?? yymmdd8.);

View solution in original post

2 REPLIES 2
Astounding
PROC Star

Using the DATE2= variation, see if you can suppress messages by adding ?? in the right place:

 

date2=input(put(year,4.)||put(month,z2.)||put(day,z2.), ?? yymmdd8.);
DDutton
Fluorite | Level 6

So embarrassed!  I forgot all about the ? and ?? modifiers! 

Thanks for the quick reminder!

dd

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
  • 2 replies
  • 1037 views
  • 0 likes
  • 2 in conversation