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.

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