SAS Data Integration Studio, DataFlux Data Management Studio, SAS/ACCESS, SAS Data Loader for Hadoop and others

Rewriting two "call symput" statements for use in macro/precode

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 90
Accepted Solution

Rewriting two "call symput" statements for use in macro/precode

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. Smiley Happy

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?


Accepted Solutions
Solution
‎10-10-2012 11:17 AM
Respected Advisor
Posts: 3,799

Re: Rewriting two "call symput" statements for use in macro/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

View solution in original post


All Replies
PROC Star
Posts: 7,471

Re: Rewriting two "call symput" statements for use in macro/precode

Posted in reply to EinarRoed

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;

Solution
‎10-10-2012 11:17 AM
Respected Advisor
Posts: 3,799

Re: Rewriting two "call symput" statements for use in macro/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

🔒 This topic is solved and locked.

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

Discussion stats
  • 2 replies
  • 344 views
  • 3 likes
  • 3 in conversation