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 🙂
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!
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.