Hi,
I am trying to create macros based on month
eg., if month is JAN FEB MAR then i need to create year macro -1 year
else i want to create macro +1 year
if Month JAN/FEB/MAR 2012 then i want to create macro year 2011
else i want to create macro year 2012
%let day='02jul2012'd ; options minoperator; %macro a; %if %sysfunc(substr(%sysfunc(putn(&day,monyy.)),1,3)) in JAN FEB MAR %then %do;data _null_;call symputx('year',year(&day)-1);stop;run;%end; %else %do;data _null_;call symputx('year',year(&day));stop;run;%end; %mend a; %a %put &year ;
Ksharp
Hi,
i the macro value (+1 year) (-1year) like that?
Thanks & Regards,
Manoj
yes
Creating macro year based on months conditionally
if month is JAN/FEB/MAR 2012 then want to create macro year=2011
else macro year=2012
And if the 'date' goes with your system time dynamically, you don't need to feed it:
data _null_;
if month(date()) in (1,2,3) then
call symputx('year',year(date())-1);
else call symputx('year',year(date()));
run;
%put &year;
Regards,
Haikuo
Thanks for support
can we select the date insted of system date the report can be generated for any month the date should vary
march to march
%let day='02jul2012'd ; options minoperator; %macro a; %if %sysfunc(substr(%sysfunc(putn(&day,monyy.)),1,3)) in JAN FEB MAR %then %do;data _null_;call symputx('year',year(&day)-1);stop;run;%end; %else %do;data _null_;call symputx('year',year(&day));stop;run;%end; %mend a; %a %put &year ;
Ksharp
Thanks Ksharp
it is working fine
title of program is report generated for the period 31 Dec 2011 for financial year 2011-2012
(if month is from april 2011 to march 2012)
if month is April 2012 then title will be " for financial year 2012-2013"
i am unable to put other date
Data _null_'s code will for you then.
Shifted interval...
29 %let day='02jul2012'd ;
30 %let year=%sysfunc(intnx(Year1.4,&day,0),year.);
31 %put YEAR=&YEAR;
YEAR=2012
35 %let day='02feb2012'd ;
36 %let year=%sysfunc(intnx(Year1.4,&day,0),year.);
37 %put YEAR=&YEAR;
YEAR=2011
Thanks for your support
i want to generate a title
if the report generating period is form April 2011 to Mar2012 then title=
"for the financial year 2011 to 2012"
if the report is generating for period dec 2011 then title will be "for the financial year 2011-2012"
if the report is generating for period jan 2012 then title will be " for the financial year 2011-2012"
I maybe misunderstand your question, but could it be done by just using the title statement?
Supposely you have already run _null_'s code:
Title "for the financial year &year.- %eval(&year.+1)";
Haikuo
How about this.
38 %let day='02feb2012'd ;
39 %let year=%sysfunc(intnx(Year1.4,&day,0,B),year.)-%sysfunc(intnx(Year1.4,&day,0,E),year.);;
40 %put YEAR=&YEAR;
YEAR=2011-2012
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.