DATA Step, Macro, Functions and more

SAS statements based on Help documents, but still produce 2 errors

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

SAS statements based on Help documents, but still produce 2 errors

[ Edited ]
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.
 

Accepted Solutions
Solution
‎11-19-2017 03:10 PM
Super User
Posts: 23,296

Re: SAS statements based on Help documents, but still produce 2 errors

Posted in reply to yuan_wang

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


All Replies
Solution
‎11-19-2017 03:10 PM
Super User
Posts: 23,296

Re: SAS statements based on Help documents, but still produce 2 errors

Posted in reply to yuan_wang

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.
 



 

 

New Contributor
Posts: 3

Re: SAS statements based on Help documents, but still produce 2 errors

[ Edited ]

Reeza,

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

Super User
Posts: 23,296

Re: SAS statements based on Help documents, but still produce 2 errors

Posted in reply to yuan_wang

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. 

New Contributor
Posts: 3

Re: SAS statements based on Help documents, but still produce 2 errors

Reeza, that's what I wanna know

Thank you very much for your prompt reply and nice help :-)

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 109 views
  • 2 likes
  • 2 in conversation