BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Mirisage
Obsidian | Level 7

Hi SAS Forum,

I found the following two statements from a code written by someone else.

%let Day_want = %sysfunc(today());

%let YYMM = %sysfunc(intnx(WEEKDAY,&Day_want,-1),yymmd.);

I can understand the use of %sysfunc in the first statement above only.

%sysfunc in the first  statement above returns the date of today as a SAS date which is then equated to a macro variable named Day_want.

Questions:

1. 1.  What is the role %sysfunc in the second statement? Is %sysfunc used for variety of things?

2. 2. In standard intnx function ‘interval’ term which is ‘WEEKDAY’ above has to be enclosed within single quotes but the second statement does not obey that rule but SAS generates the results.

Could someone help me.

Miris

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

RTM:

SAS(R) 9.2 Macro Language: Reference

Execute SAS functions or user-written functions.

...


Details

Because %SYSFUNC is a macro function, you do not need to enclose character values in quotation marks as you do in DATA step functions. For example, the arguments to the OPEN function are enclosed in quotation marks when the function is used alone, but do not require quotation marks when used within %SYSFUNC....

Your interpretation of the first step is also wrong. It is calling the function today in the first and the in the second it is calling a different function, intnx.

To use a sas function in open macro code, you need to to use SYSFUNC or QSYSFUNC to tell SAS that its not just text.

View solution in original post

2 REPLIES 2
Reeza
Super User

RTM:

SAS(R) 9.2 Macro Language: Reference

Execute SAS functions or user-written functions.

...


Details

Because %SYSFUNC is a macro function, you do not need to enclose character values in quotation marks as you do in DATA step functions. For example, the arguments to the OPEN function are enclosed in quotation marks when the function is used alone, but do not require quotation marks when used within %SYSFUNC....

Your interpretation of the first step is also wrong. It is calling the function today in the first and the in the second it is calling a different function, intnx.

To use a sas function in open macro code, you need to to use SYSFUNC or QSYSFUNC to tell SAS that its not just text.

Amir
PROC Star

Hi,

Both answers are taken from the documentation:

SAS(R) 9.2 Macro Language: Reference

1) "Execute SAS functions or user-written functions"

2) "Because %SYSFUNC is a macro function, you do not need to enclose character values in quotation marks as you do in DATA step functions."

Regards,

Amir.

sas-innovate-2024.png

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.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 783 views
  • 3 likes
  • 3 in conversation