I would like to create macro program for the following purpose:
I have a data set (abcsales) that have following variables: ID sales date month country, etc.
I would like to have statistics of sales variable to be shown by inputting the month and country in my macro program:
I have done the following:
%MACRO create_sales_month_country(data,month,country);
proc univariate data=&data;
class &month &country;
var sales;
run;
%MEND;
but by doing that, it will return sales by all countries with different months.
What I would like to achieve is input a specific month and a specific country then return me the statistic results of that specific country at a specific month.
I know that I could use keywords variables in my macro program for example:
%MACRO create_sales_month_country(data,month="April",country="Mexico");
but I need to change each time the value of the parameter to get another country's statistics.
I'm wondering if there is a "where statement" that I could use in the "proc univariate" that will allow me to sort the dataset with the specific month and country and then output the statistics that I would like to have for the desired country with the desired month.
I have tried the following:
%MACRO create_sales_month_country(data,month,country);
proc univariate data=&data;
class &month &country;
var sales;
where month = "&month" and country = "&country"
run;
%MEND;
But the above code doesn't work at all.
Could you please help me to find a solution with the code which could achieve what I would like to do ?
Thank you !
options mprint symbolgen;then call the macro%create_sales_month_country(myData, 1, Canada);and post the full log to help us help you debug any issues.