The two following code lines, which are taken from a DATA step, need to be rewritten so that they can be used in a macro:
%call symput('startdato', %put(intnx('week',today(), -1, 'beginning')+2, nordfde9.));
%call symput('sluttdato', %put(intnx('week',today(), 0, 'beginning')+1, nordfde9.));
At first I figured I might do it like this:
%let startdato = %intnx('week',today(), -1, 'beginning') +2;
%let sluttdato = %intnx('week',today(), 0, 'beginning') +1;
%put(startdato, nordfde9.);
%put(sluttdato, nordfde9.);
However, apparently that doesn't work. Can someone please advise me on how to resolve this?
Thanks.
UPDATE: What I need is create a macrovariable that says for example "02oct2012-08oct2012" (if the job was run today). The INTNX-logic works in a DATA step, so that's not a problem. I can write %let week_period = &sysdate.-&sysdate.; to get 10OCT12-10OCT12, but how do I apply the INTNX and formatting properly in DI Studio precode?
Using a shifted interval makes it a bit easier. I think :smileyplain:
22 %let startdato = %sysfunc(intnx(week1.3,%sysfunc(today()),-1,b),nordfde9.);
23 %let sluttdato = %sysfunc(intnx(week1.3,%sysfunc(today()),-1,e),nordfde9.);
24 %put &startdato - &sluttdato;
02okt2012 - 08okt2012
I wrote the following before I saw your update. Can you expand it to do what you need?:
%let startdato = %sysfunc(putn(%eval(%sysfunc(intnx(week,%sysfunc(today()), -1, beginning)) +2),nordfde9.));
%let sluttdato = %sysfunc(putn(%eval(%sysfunc(intnx(week,%sysfunc(today()), 0, beginning)) +1),nordfde9.));
%put &startdato;
%put &sluttdato;
Using a shifted interval makes it a bit easier. I think :smileyplain:
22 %let startdato = %sysfunc(intnx(week1.3,%sysfunc(today()),-1,b),nordfde9.);
23 %let sluttdato = %sysfunc(intnx(week1.3,%sysfunc(today()),-1,e),nordfde9.);
24 %put &startdato - &sluttdato;
02okt2012 - 08okt2012
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!
Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.
Find more tutorials on the SAS Users YouTube channel.