data _null_;
call symputx('Fetch_COM', put(intnx ('month',today(),0, 'b') + 1 ,yymmddn8.) );
run;
%put &Fetch_COM;
We all have needs.
I have needs too.
I need you to tell me the names of the variables that you have to work with, and give a couple of examples of the values they contain and the result that you would like.
data _null_;
call symputx('Fetch_COM', put(intnx ('month',today(),-2, 'b') + 27 ,yymmddn8.) );
run;
I HAVE THE VARIABLE "Fetch COM"
SHE GIVES ME AS a RESULT 20190228
I NEED a VARIABLE TO DELIVER ME AS a RESULT 20190402
THE CURRENT DATE WITH DAY 2
data _null_;
call symputx('Fetch_COM', put(intnx ('month',today(),0, 'b') + 1 ,yymmddn8.) );
run;
%put &Fetch_COM;
@yesidgranadosv wrote:
data _null_;
call symputx('Fetch_COM', put(intnx ('month',today(),-2, 'b') + 27 ,yymmddn8.) );
run;I HAVE THE VARIABLE "Fetch COM"
SHE GIVES ME AS a RESULT 20190228
I NEED a VARIABLE TO DELIVER ME AS a RESULT 20190402
THE CURRENT DATE WITH DAY 2
I think this means you didn't understand the code provided previously.
27 puts the date at 27+1 =28 days. If you want day 2, change the 27 accordingly to get the date you want.
@yesidgranadosv wrote:
data _null_;
call symputx('Fetch_COM', put(intnx ('month',today(),-2, 'b') + 27 ,yymmddn8.) );
run;I HAVE THE VARIABLE "Fetch COM"
SHE GIVES ME AS a RESULT 20190228
I NEED a VARIABLE TO DELIVER ME AS a RESULT 20190402
THE CURRENT DATE WITH DAY 2
That's not quite correct and please don't type in all upper case, it's the equivalent of yelling.
You're creating a macro variable, named Fetch_CON, that is the second day of the current year and month. You do not have a variable with that value nor are you using data from a data set.
TODAY() returns the current date
INTNX() moves that date to the beginning of the month, since the first parameter is month and the last paramter is 'b' for beginning of the month.
+1/27 adds the number of days to the month as needed.
YYMMDDN formats the date to appear in your desired format, although it's still a SAS date underneath. If you're planning to work more with dates and macro variables, I highly recommend reading the date and time tutorials here, you'll save yourself a lot of time:
or more specifically, this PDF file attached.
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!
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.