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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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