BookmarkSubscribeRSS Feed
yesidgranadosv
Obsidian | Level 7

 

 

 

data _null_;
call symputx('Fetch_FIN', put(intnx ('month',today(),0, 'b') + 1 ,yymmddn8.) );
run;

%put Fetch_FIN = &Fetch_FIN.;

 

result = 20190501

 
Actually I want to have the result of the current day without needing to add the days (+1...) 
Dynamic function
 
 
4 REPLIES 4
PaigeMiller
Diamond | Level 26
data _null_;
    today=today(); 
    call symputx('today',today);
    call symputx('year',year(today));
    call symputx('month',month(today));
    call symputx('day',day(today));
run;

I'm not sure what you are trying to accomplish, and I'm not sure of what the +1 is doing, but some part of the above ought to be what you want. 

 

I would also say that you most likely DO NOT want a macro variable that has value 20190501, that's pretty useless as a value. You do want a macro variable like TODAY computed above that actually contains the SAS date value for May 1, 2019.

--
Paige Miller
ballardw
Super User

@yesidgranadosv wrote:

 

 

 

data _null_;
call symputx('Fetch_FIN', put(intnx ('month',today(),0, 'b') + 1 ,yymmddn8.) );
run;

%put Fetch_FIN = &Fetch_FIN.;

 

result = 20190501

 
Actually I want to have the result of the current day without needing to add the days (+1...) 
Dynamic function
 
 

Can you describe why if you want "current day" you are messing around with modifying the "month"?. Or do you mean something like "first of the month" instead of "current day"?

Given that today is 16MAY2019 what is your desired output?

Note that the +1 is not needed if you expect to get 20190501

248  data _null_;
249  call symputx('Fetch_FIN', put(intnx ('month',today(),0, 'b') ,yymmddn8.) );
250  run;

NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.01 seconds


251
252  %put Fetch_FIN = &Fetch_FIN.;
Fetch_FIN = 20190501

Or is this what you want:

260  data _null_;
261  call symputx('Fetch_FIN', put(today() ,yymmddn8.) );
262  run;

NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


263
264  %put Fetch_FIN = &Fetch_FIN.;
Fetch_FIN = 20190516

 

PGStats
Opal | Level 21

There is no such format as yymmddn8. to translate the SAS date (number) into a string. Try this instead:

 


data _null_;
call symputx('Fetch_FIN', put(intnx ('month',today(),0, 'b') + 1 ,yymmdd10.) );
run;

%put Fetch_FIN = &Fetch_FIN.;
PG
ballardw
Super User

@PGStats wrote:

There is no such format as yymmddn8. to translate the SAS date (number) into a string. Try this instead:

 


data _null_;
call symputx('Fetch_FIN', put(intnx ('month',today(),0, 'b') + 1 ,yymmdd10.) );
run;

%put Fetch_FIN = &Fetch_FIN.;

N is an option in the YYMMDDxw. format. When the N replaces the X there is not separator between the year month and day,

B places a space, C a colon, D a hyphen (dash), P period as separators

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 639 views
  • 0 likes
  • 4 in conversation