Hello
I have the following question
I define the following parameter of dates (YYMM).
%let vector=1708+1707+1706+1612;
I want to create base on vector parameter another parameter called tarr that includes also 4 arguments with + symbol between them.
Each argument is created by subscribing 12 months and take end of month.
The wanted parameter is
'31AUG2016'd+'31JUL2016'd+'30JUN2016'd+31DEC2015'd
Can anyone help to do it please?
Thanks
To what purpose? Data should go in datasets, datasets and Base SAS are created to manipulate and use data, hence why they have the various formats and functions. Macro is not for processing data it is a text find an replace system. Your wanted is just a more complicated way of refering to the numbers already there.
Now you can do it of course, but it really isn't good practice as your just patching bad code:
%let vector=1707+1708+1706+1608; data _null_; length tmp $2000; do i=1 to countw("&vector."); tmp=catx('+',tmp,cats("'",put(input(scan("&vector.",i,"+"),best.),date9.),"'d")); end; call symputx('want',tmp); run; %put &want.;
However there is nothing redeeming about coding like that whatsoever.
Hello
Thanks for your reply.
The code is running well but the output dates are not as we want.
%let vector=1707+1708+1706+1608;
The required output is
%let tarr='31Aug2016'd+'31Jul2016'd+'30Jun2016'd+'31Dec2015'd;
(It is calculated by minus 12 months and taking end of month )
thanks
Ronein
Hello
I have the following question
I define the following parameter of dates (YYMM).
%let vector=1708+1707+1706+1612;
I want to create base on vector parameter another parameter called tarr that includes also 4 arguments with + symbol between them.
Each argument is created by subscribing 12 months and take end of month.
The wanted parameter is
'31AUG2016'd+'31JUL2016'd+'30JUN2016'd+31DEC2015'd
Can anyone help to do it please?
I know that in order to find end of month date we can use the function
intnx('month',mon_now_minus12M_date,0,'E')
Thanks
"
I know that in order to find end of month date we can use the function
intnx('month',mon_now_minus12M_date,0,'E')
"
Even more reason to use Base SAS then, you have the given formula, use that in code, still don't see what a parameter list fits in?
Ah, ok, then use the intnx function like this:
%let vector=1707+1708+1706+1608; data test /*_null_*/; length tmp $2000; do i=1 to countw("&vector."); pdate=intnx('month',input(cats(scan("&vector.",i,"+"),"01"),yymmdd8.),-12,"e"); tmp=catx('+',tmp,cats("'",put(pdate,date9.),"'d")); end; call symputx('want',tmp); run; %put &want.;
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.