BookmarkSubscribeRSS Feed
Kurt_Bremser
Super User

@Tom wrote:

@Kurt_Bremser wrote:

Subtract 7 from the date. To make (integer) calculations in macro language, use the %EVAL function:

%let d=%sysfunc(week(%eval(%sysfunc(today())-7)),z2.);

Note that if the expression is being passed as an argument to a SAS function via %SYSFUNC() you don't need to use %EVAL() to do the calculations before hand.

338   %let x1=%sysfunc(week(%eval(%sysfunc(today())-7)),z2.);
339   %let x2=%sysfunc(week(%sysfunc(today())-7),z2.);
340
341   %put &=x1 &=x2;
X1=10 X2=10

A NUMERIC argument that is.

346   %put |%sysfunc(putn(5+6,Z5.))|;
|00011|
347   %put |%sysfunc(putc(5+6,$5.-R))|;
|  5+6|

And - tadaa! - once again I learned something new here.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 15 replies
  • 1708 views
  • 3 likes
  • 4 in conversation