Hi Arimitra, I think it quite easy by using DATA step rather than complex query...Based on your .JPG file, the output you want is the Total Count of distinct subcategories as well as SUM of distinct categories... Please try the following SAS Code... proc sort data = have; by subcategory; run; data want; set have; by subcategory; if first.subcategory then do; count = 0; total_sales = sales; end; else do; count + 1; total_sales + sales; end; if last.subcategory; run; And ya one more thing to say in this case is that if you supply COUNT(DISTINCT Subcategory) then SAS has to two pass through the data that is one time it will remove the duplicates and then in second pass it will count...So of cource if you have more subcategories then it will take much and muchhh time....So either use Proc Freq or Proc Sort followed by Data Step... Thanks, Urvish
... View more