The documentation is correct, but you need to wrap it in a data step.
data _null_;
x = weekday('16Mar97'd);
put x;
run;
If you don't want/need a data step, you can do it within macro functions but I suspect that's not what you're looking for at the moment.
@yuan_wang wrote:
SAS Help DocumentsWEEKDAY Function>> My commentsEven if I write the WEEKDAY Functions according to SAS Help documents, they still produce the Two Errors.Is SAS Official Document fooling users? A bit weird~~Can you help me find the reason? Thanks 🙂/* EX01_test *//* WEEKDAY Functions according to SAS Help documents *//* Two Errors */x=weekday('16mar97'd);put x;Two Errors in SAS Log62 /* EX01_test */636465 x=weekday('16mar97'd);_180ERROR 180-322: Statement is not valid or it is used out of proper order.66 put x;___180ERROR 180-322: Statement is not valid or it is used out of proper order.
The documentation is correct, but you need to wrap it in a data step.
data _null_;
x = weekday('16Mar97'd);
put x;
run;
If you don't want/need a data step, you can do it within macro functions but I suspect that's not what you're looking for at the moment.
@yuan_wang wrote:
SAS Help DocumentsWEEKDAY Function>> My commentsEven if I write the WEEKDAY Functions according to SAS Help documents, they still produce the Two Errors.Is SAS Official Document fooling users? A bit weird~~Can you help me find the reason? Thanks 🙂/* EX01_test *//* WEEKDAY Functions according to SAS Help documents *//* Two Errors */x=weekday('16mar97'd);put x;Two Errors in SAS Log62 /* EX01_test */636465 x=weekday('16mar97'd);_180ERROR 180-322: Statement is not valid or it is used out of proper order.66 put x;___180ERROR 180-322: Statement is not valid or it is used out of proper order.
Reeza,
Yup, Your revised version has no errors, but how can I get the value of X?
What do you mean? If you're trying to see where the X information is printed to, then check the LOG, the results are in the LOG.
That's what the PUT statement does, it prints information to the LOG.
If you want it in a data set, don't use _NULL_, give it a name and then PRINT the results.
Reeza, that's what I wanna know
Thank you very much for your prompt reply and nice help 🙂
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.