BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
yuan_wang
Fluorite | Level 6
SAS Help Documents
WEEKDAY Function
 
 
 
>> My comments
Even 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 Log
 
62 /* EX01_test */
63
64
65 x=weekday('16mar97'd);
_
180
 
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
66 put x;
___
180
 
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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 Documents
WEEKDAY Function
 
 
 
>> My comments
Even 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 Log
 
62 /* EX01_test */
63
64
65 x=weekday('16mar97'd);
_
180
 
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
66 put x;
___
180
 
ERROR 180-322: Statement is not valid or it is used out of proper order.
 



 

 

View solution in original post

4 REPLIES 4
Reeza
Super User

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 Documents
WEEKDAY Function
 
 
 
>> My comments
Even 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 Log
 
62 /* EX01_test */
63
64
65 x=weekday('16mar97'd);
_
180
 
ERROR 180-322: Statement is not valid or it is used out of proper order.
 
66 put x;
___
180
 
ERROR 180-322: Statement is not valid or it is used out of proper order.
 



 

 

yuan_wang
Fluorite | Level 6

Reeza,

Yup, Your revised version has no errors, but how can I get the value of X?

Reeza
Super User

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. 

yuan_wang
Fluorite | Level 6

Reeza, that's what I wanna know

Thank you very much for your prompt reply and nice help 🙂

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 4 replies
  • 1474 views
  • 2 likes
  • 2 in conversation