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 🙂

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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