vuppalanchi
Programmer
Hello there,
I have been trying to use the sas inbuilt function MONTH to extract the month of a particular transaction date. And I need to write same set of steps for all the 12 months and therefore tried using macro. I am not sure how SAS recognizes functions within a macro. I have also tried using %sysfunc tool before the month function but its not working since I guess %sysfunc supports limited set of functions. Following is the code I was trying. Let me know if there any ways to handle this.
libname temp '/pool_mo_2007';
libname tempfile '/cii/phase4/work';
%macro transaction(outputdata,inputdata,monum,moname);
data tempfile.&outputdata;
set temp.&inputdata (keep=tdate);
informat tdate mmddyy6.;
%if %sysfunc(MONTH(tdate))=&monum %then current_month=1;
%else
%if %sysfunc(MONTH(tdate))=&monum-1 %then last_month=1;
%else other_months=1;
proc means data=tempfile.&outputdata N;
var current_month last_month other_months;
title 'Transaction Summary for the month of &moname';
run;
%mend;
I have been trying to use the sas inbuilt function MONTH to extract the month of a particular transaction date. And I need to write same set of steps for all the 12 months and therefore tried using macro. I am not sure how SAS recognizes functions within a macro. I have also tried using %sysfunc tool before the month function but its not working since I guess %sysfunc supports limited set of functions. Following is the code I was trying. Let me know if there any ways to handle this.
libname temp '/pool_mo_2007';
libname tempfile '/cii/phase4/work';
%macro transaction(outputdata,inputdata,monum,moname);
data tempfile.&outputdata;
set temp.&inputdata (keep=tdate);
informat tdate mmddyy6.;
%if %sysfunc(MONTH(tdate))=&monum %then current_month=1;
%else
%if %sysfunc(MONTH(tdate))=&monum-1 %then last_month=1;
%else other_months=1;
proc means data=tempfile.&outputdata N;
var current_month last_month other_months;
title 'Transaction Summary for the month of &moname';
run;
%mend;