title: What is the equivalent to grouping sets in SAS Proc Sql?
body: <p>I have a Teradata query that has a group by and then uses grouping sets to sum up the groups in a total line:</p>
  
  <pre><code>SELECT mygroup, count(x), sum(y)
  FROM mytable
  ORDER BY GROUPING (mygroup),mygroup
  GROUP BY mygroup GROUPING SETS ((mygroup),())
  </code></pre>
  
  <p>I am now writing the same query in SAS EG as I want to create a scheduled report to be sent by email. </p>
  
  <p>SAS EG does not have grouping sets as far as I can google.</p>
  
  <p>My question is how I can create this "summary line" in SAS <code>PROC SQL</code>, or possibly by some other SAS EG magic?</p>
  
  <p>Edit: Here is an example of the output I am looking for:
  <a href="https://i.stack.imgur.com/sQZEN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sQZEN.png" alt="Excel version of my desired output"></a></p>
  
  <p>It is the total line I lack in SAS EG so far</p>
  
  <p>Update:
  I have now written a <code>Proc Tabulate</code> and I am near my goal. The only field I cannot seem to get correct is the total percentage difference. In the table I have made a total line where I sum <code>Number1</code> and 2, but for the percentage total I want a calculation of (Number1-Number2)/Number1 instead of a sum or other aggregate. Is this possible with tabulate, and how do I do it?</p>
  
  <p>My current code:</p>
  
  <pre><code>PROC TABULATE
  DATA=WORK.TEMP;
  
  VAR Number1 Number2 percentageCalc ;
  CLASS group /   ORDER=UNFORMATTED MISSING;
  CLASS date /    ORDER=UNFORMATTED MISSING;
  TABLE 
      /* ROW Statement */
      group*date
      all = 'Total'  ,
      /* COLUMN Statement */
      (Number1 * Sum={LABEL="Sum"} Number2 * Sum={LABEL="Sum"} percentageCalc  * Sum={LABEL="%"} )        ;
  ;
  
  RUN;
  </code></pre>
  
  <p>Is there any way to do a manual calculation in my last total cell or can I somehow manually create the whole total line?</p>