Hi All, I have a table of 1500 observations with Subcategory and their Sales value. I want to find out the count of each subcategory group by subcategory in one table. In total there are 6 unique subcategories. proc sql noprint; count(distinct Subcategory) :n candy_sales_summary; distinct(Subcategory) :C1 - :C%left(&n) candy_sales_summary; ; %put &n; %put &C3; I am unable to complete the below code. %macro calc; %let i = &n; %let j = %eval(&n - 1); %do %until (&i ge &j); proc sql; create table Test as select Subcategory,count(Subcategory) as Units from candy_sales_summary where Subcategory in ("&&C&i") group by Subcategory union all select Subcategory,count(Subcategory) as Units from candy_sales_summary where Subcategory in ("&&C&j") group by Subcategory ; quit; run; %end; %mend calc; %calc; Is there any way in sql where I can iteratively append the count of each subcategory in one table For example when I run this, I get count of only two, when I need all 6 in one table proc sql; select Subcategory,count(Subcategory) as Units from candy_sales_summary where Subcategory in ('Mixed') group by Subcategory union all select Subcategory,count(Subcategory) as Units from candy_sales_summary where Subcategory in ('Gum') group by Subcategory ; quit; Please help
... View more