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
Why does the if statement not work? I have tried almost everything in regards to date formats.
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?
Hi,
use
'30Apr2019'd
or
mdy(04,30,2019)
- Cheers -
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.