BookmarkSubscribeRSS Feed
sasprogramming
Quartz | Level 8
data moomoo;
set moo;
if DATE= '2019-04-30'd	 then  dummy= 1;
run;
 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         data moomoo;
 74         set moo;
 75         if PORTFOLIO_DATE = '2019-04-30'd then  dummy= 1;
                                _____________
                                77
 ERROR: Invalid date/time/datetime constant '2019-04-30'd.
 ERROR 77-185: Invalid number conversion on '2019-04-30'd.
 
 77         run;
 
 NOTE: The SAS System stopped processing this step because of errors.
 WARNING: The data set WORK.MOOMOO may be incomplete.  When this step was stopped there were 0 observations and 8 variables.
 WARNING: Data set WORK.MOOMOO was not replaced because this step was stopped.
 NOTE: DATA statement used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 
 78         
 79         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 92     
 

 

sasprogramming_0-1621920181741.pngsasprogramming_1-1621920195757.png

Why does the if statement not work? I have tried almost everything in regards to date formats.

 

2 REPLIES 2
ballardw
Super User

The date value must be in one of the forms the DATE. format uses such as "30Apr2019"d.

 

There are just too many random sequences of digits to provide all of them as date literal values, partially because some of them are just plain too ambiguous. Consider, what date would '01-02-03' mean?

Oligolas
Barite | Level 11

Hi,

use 

'30Apr2019'd

or

mdy(04,30,2019)
________________________

- Cheers -

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 564 views
  • 0 likes
  • 3 in conversation