<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Subtotals and Grand Total in dataset with transpose in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527596#M143858</link>
    <description>&lt;DIV&gt;Hi, I'd like to request assistance again in getting the subtotals and totals from this dataset, also transposing the variable "class" from long to wide. Let's say I would not have any idea how many distinct values of "class" will there be.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;My preferred result would be a SAS dataset, in "WANT2".&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Thank you!&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data have2;&lt;BR /&gt;input Group_Name :$20. Member :$20. class $4. num;&lt;BR /&gt;datalines;&lt;BR /&gt;Group_a Member_a_1 num1 6&lt;BR /&gt;Group_a Member_a_2 num1 4&lt;BR /&gt;Group_b Member_b_1 num1 6&lt;BR /&gt;Group_b Member_b_2 num1 3&lt;BR /&gt;Group_a Member_a_1 num2 0&lt;BR /&gt;Group_a Member_a_2 num2 1&lt;BR /&gt;Group_b Member_b_2 num2 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data want2;&lt;BR /&gt;input final_text :$20. num1 num2;&lt;BR /&gt;datalines;&lt;BR /&gt;Grand_Total 19 5&lt;BR /&gt;Group_a 10 1&lt;BR /&gt;Member_a_1 6 0&lt;BR /&gt;Member_a_2 4 1&lt;BR /&gt;Group_b 9 4&lt;BR /&gt;Member_b_1 9 3&lt;BR /&gt;Member_b_2 0 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/DIV&gt;</description>
    <pubDate>Wed, 16 Jan 2019 02:22:28 GMT</pubDate>
    <dc:creator>angeliquec</dc:creator>
    <dc:date>2019-01-16T02:22:28Z</dc:date>
    <item>
      <title>Subtotals and Grand Total in dataset with transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527596#M143858</link>
      <description>&lt;DIV&gt;Hi, I'd like to request assistance again in getting the subtotals and totals from this dataset, also transposing the variable "class" from long to wide. Let's say I would not have any idea how many distinct values of "class" will there be.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;My preferred result would be a SAS dataset, in "WANT2".&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Thank you!&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data have2;&lt;BR /&gt;input Group_Name :$20. Member :$20. class $4. num;&lt;BR /&gt;datalines;&lt;BR /&gt;Group_a Member_a_1 num1 6&lt;BR /&gt;Group_a Member_a_2 num1 4&lt;BR /&gt;Group_b Member_b_1 num1 6&lt;BR /&gt;Group_b Member_b_2 num1 3&lt;BR /&gt;Group_a Member_a_1 num2 0&lt;BR /&gt;Group_a Member_a_2 num2 1&lt;BR /&gt;Group_b Member_b_2 num2 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;data want2;&lt;BR /&gt;input final_text :$20. num1 num2;&lt;BR /&gt;datalines;&lt;BR /&gt;Grand_Total 19 5&lt;BR /&gt;Group_a 10 1&lt;BR /&gt;Member_a_1 6 0&lt;BR /&gt;Member_a_2 4 1&lt;BR /&gt;Group_b 9 4&lt;BR /&gt;Member_b_1 9 3&lt;BR /&gt;Member_b_2 0 1&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/DIV&gt;</description>
      <pubDate>Wed, 16 Jan 2019 02:22:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527596#M143858</guid>
      <dc:creator>angeliquec</dc:creator>
      <dc:date>2019-01-16T02:22:28Z</dc:date>
    </item>
    <item>
      <title>Re: Subtotals and Grand Total in dataset with transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527604#M143864</link>
      <description>Do you want a data set or a displayed report? &lt;BR /&gt;Otherwise use PROC MEANS with a CLASS statement to get the sun totals and totals. Put the grouping variables in the CLASS statement and variables you want summarized in the VAR statement.</description>
      <pubDate>Wed, 16 Jan 2019 02:15:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527604#M143864</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-01-16T02:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Subtotals and Grand Total in dataset with transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527605#M143865</link>
      <description>&lt;P&gt;Hi Reeza. I'd like to have a dataset. Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jan 2019 02:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527605#M143865</guid>
      <dc:creator>angeliquec</dc:creator>
      <dc:date>2019-01-16T02:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Subtotals and Grand Total in dataset with transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527607#M143866</link>
      <description>&lt;P&gt;Did not get your requirements completely, see if this helps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have2;
input Group_Name :$20. Member :$20. class $4. num;
datalines;
Group_a Member_a_1 num1 6
Group_a Member_a_2 num1 4
Group_b Member_b_1 num1 6
Group_b Member_b_2 num1 3
Group_a Member_a_1 num2 0
Group_a Member_a_2 num2 1
Group_b Member_b_2 num2 1
;
run;

proc means data=have2 nway noprint n ;
class Group_Name Member;
var num;
ways 0 1 2;
output out=want(drop=_type_ _freq_ _way_)  sum=/ ways;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Jan 2019 02:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527607#M143866</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-01-16T02:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Subtotals and Grand Total in dataset with transpose</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527656#M143904</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;

data have2;
input Group_Name :$20. Member :$20. class $4. num;
datalines;
Group_a Member_a_1 num1 6
Group_a Member_a_2 num1 4
Group_b Member_b_1 num1 6
Group_b Member_b_2 num1 3
Group_a Member_a_1 num2 0
Group_a Member_a_2 num2 1
Group_b Member_b_2 num2 1
;
run;
proc summary data=have2 nway;
class  Group_Name  Member class;
var num;
output out=temp(drop=_:) sum=;
run;
proc transpose data=temp out=temp1(drop=_:);
by Group_Name  Member;
id class;
var num;
run;


ods select none;
proc report data=temp1 out=want nowd;
column  Group_Name  Member  num1 num2;
define Group_Name/order;
compute before;
 Member='Grand_Total';
endcomp;
compute before Group_Name;
 Member=Group_Name;
endcomp;
break before Group_Name/summarize;
rbreak before/summarize;
run;
ods select all;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Jan 2019 08:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Subtotals-and-Grand-Total-in-dataset-with-transpose/m-p/527656#M143904</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-01-16T08:31:55Z</dc:date>
    </item>
  </channel>
</rss>

