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

Hi,

 

strange thing happens when I try the following:

%let DATE  = %sysfunc(intnx(day,%sysfunc(TODAY()),-1),yymmddd10.); run;

 

it works fine and shows as result: 2017-03-18 (as today is the 19th, and yesterday was the 18th, so it's okay).

 

But, when you try:

%let test = %sysfunc(cat(Keep Attention ,&datum)); %put &test;

 

you will see that the result is not Keep Attention 2017-03-18, but it's like  Keep Attention1988 which seems very strange to me.

 

Anyone any idea how I can concate the string "2017-03-18" or any similar to an string? The other date formats work fine, but that's not the point.

 

Regards, Vic

1 ACCEPTED SOLUTION

Accepted Solutions
Vic
Fluorite | Level 6 Vic
Fluorite | Level 6

okay, wow, it works. I will try to embed it into a macro, but I don't see that it won't be the right solution. I very think your're right.

 

It will be something like this at the end:

 

%let TEST = MIS 1234 - P9 EXECUTIVE REPORT Export &&DATE&; 

 

 

within a macro but I will try tomorrow (as it is late now here in Germany :)).

 

Regards, Vic

View solution in original post

5 REPLIES 5
Astounding
PROC Star

It doesn't seem too strange that the combination of %SYSFUNC and CAT might strip the elements being concatenated.  1988 is indeed strange.  I could imagine getting 1996 if that combination of %SYSUNC and CAT were to actually perform the subtraction (2017 minus 3 minus 18).  At any rate, macro language is built to concatenate character strings without functions.  Try:

 

%let test = Keep Attention &datum;

 

That should handle the problem nicely.

Vic
Fluorite | Level 6 Vic
Fluorite | Level 6

Hi,

 

thank you very much for answering. My point is/was that I use it within a macro as it reads multiple Excelfiles. But maybe my way is not very productive, so I will try your proposal.

 

I will report if it works :).

 

Regards, Vic

Vic
Fluorite | Level 6 Vic
Fluorite | Level 6

okay, wow, it works. I will try to embed it into a macro, but I don't see that it won't be the right solution. I very think your're right.

 

It will be something like this at the end:

 

%let TEST = MIS 1234 - P9 EXECUTIVE REPORT Export &&DATE&; 

 

 

within a macro but I will try tomorrow (as it is late now here in Germany :)).

 

Regards, Vic

rogerjdeangelis
Barite | Level 11
I get 1996

%let DATE  = %sysfunc(intnx(day,%sysfunc(TODAY()),-1),yymmddd10.); run;
%let test = %sysfunc(cat(Keep Attention ,&date)); %put &test;

2817  %let DATE  = %sysfunc(intnx(day,%sysfunc(TODAY()),-1),yymmddd10.); run;
2818  %let test = %sysfunc(cat(Keep Attention ,&date)); %put &test;
SYMBOLGEN:  Macro variable DATE resolves to 2017-03-18
SYMBOLGEN:  Macro variable TEST resolves to Keep Attention1996

Keep Attention1996

2017 - 03 - 18 = 1996

2017 - 3 = 2015
2015 - 18 = 1996

rogerjdeangelis
Barite | Level 11
some solutions;

%symdel test date /nowarn;
%let DATE  = %sysfunc(intnx(day,%sysfunc(TODAY()),-1),yymmddd10.); run;
%let test = %sysfunc(cat(Keep Attention)) &date; %put &test;

Keep Attention 2017-03-18

%symdel test date tst /nowarn;
%let DATE  = %sysfunc(intnx(day,%sysfunc(TODAY()),-1),yymmddd10.); run;
%let test = %sysfunc(cat(Keep Attention,'&date')); %put &test;
%let tst=%sysfunc(compress(&test,%str('')));%put &tst;

Keep Attention 2017-03-18

or

data _null_;

  date=put(intnx('day',%sysfunc(TODAY()),-1),yymmddd10.);
  test = cat('Keep Attention' ,date);
  put test;

run;quit;

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!

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
  • 5 replies
  • 10448 views
  • 3 likes
  • 3 in conversation