i made a small change to the code and it worked. i've put 'and' instead of 'or' %macro freq(year=,type=); proc sql; select product_id,total_sales,order_type,year from( select product_id,year(order_date) as year ,order_type ,sum(quantity) as total_sales from sales_data group by 1,2,3)%if %length(&type)>0 %then %do; where year=&year and order_type=&type;%end;%else %do;where year=&year;%end; quit; %mend; %freq(year=2007);
... View more