<?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 Re: Get distinct group wise summary in SAS like pivot table in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Get-distinct-group-wise-summary-in-SAS-like-pivot-table/m-p/728849#M226795</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA= HAVE;
  BY NAME;
DATA WANT;
  SET  HAVE;
    BY NAME;
  retain SUM_NO;
  IF FIRST.NAME 
    THEN SUM_NO=0
    ELSE SUM_NO+1;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You'll have better results if you use a RETAIN statement.&amp;nbsp; Previously, in your given code, SUM_NO was set to MISSING every time the data step loaded another record.&lt;/P&gt;</description>
    <pubDate>Wed, 24 Mar 2021 18:22:21 GMT</pubDate>
    <dc:creator>PhilC</dc:creator>
    <dc:date>2021-03-24T18:22:21Z</dc:date>
    <item>
      <title>Get distinct group wise summary in SAS like pivot table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-distinct-group-wise-summary-in-SAS-like-pivot-table/m-p/728837#M226786</link>
      <description>&lt;P&gt;Hi Sir,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a data set : HAVE&lt;/P&gt;&lt;P&gt;and i want to get output WANT mentioned in the attachment&amp;nbsp; :&lt;/P&gt;&lt;P&gt;I have already tried below option but not working for me.&lt;/P&gt;&lt;P&gt;PROC SORT DATA= HAVE;&lt;/P&gt;&lt;P&gt;BY NAME;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;/P&gt;&lt;P&gt;SET&amp;nbsp; HAVE;&lt;/P&gt;&lt;P&gt;BY&amp;nbsp;NAME;&lt;/P&gt;&lt;P&gt;IF FIRST.NAME THEN&amp;nbsp;SUM_NO=0&lt;/P&gt;&lt;P&gt;ELSE&amp;nbsp;SUM_NO+1;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly help me to find the result.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 17:53:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-distinct-group-wise-summary-in-SAS-like-pivot-table/m-p/728837#M226786</guid>
      <dc:creator>karthik18</dc:creator>
      <dc:date>2021-03-24T17:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Get distinct group wise summary in SAS like pivot table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-distinct-group-wise-summary-in-SAS-like-pivot-table/m-p/728839#M226788</link>
      <description>&lt;P&gt;Many of us will not open attachments. If it shows the desired output, put a screen capture in your reply.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From your description, I don't see where "pivot table" applies here. Also, PROC SUMMARY gets these groupwise sums pretty quickly and easily.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=have nway;
    class name;
    var numeric_variable;
    output out=want n=sum_no;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Mar 2021 18:30:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-distinct-group-wise-summary-in-SAS-like-pivot-table/m-p/728839#M226788</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-24T18:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: Get distinct group wise summary in SAS like pivot table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-distinct-group-wise-summary-in-SAS-like-pivot-table/m-p/728849#M226795</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA= HAVE;
  BY NAME;
DATA WANT;
  SET  HAVE;
    BY NAME;
  retain SUM_NO;
  IF FIRST.NAME 
    THEN SUM_NO=0
    ELSE SUM_NO+1;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You'll have better results if you use a RETAIN statement.&amp;nbsp; Previously, in your given code, SUM_NO was set to MISSING every time the data step loaded another record.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 18:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-distinct-group-wise-summary-in-SAS-like-pivot-table/m-p/728849#M226795</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-03-24T18:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get distinct group wise summary in SAS like pivot table</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Get-distinct-group-wise-summary-in-SAS-like-pivot-table/m-p/728850#M226796</link>
      <description>&lt;P&gt;You get the same results without RETAIN, which is not needed for the sum statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA= sashelp.class out=have;
  BY sex;
DATA WANT;
  SET  HAVE;
    BY sex;
  IF FIRST.sex 
    THEN SUM_NO=0;
    ELSE SUM_NO+1;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I think the original post from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/287036"&gt;@karthik18&lt;/a&gt;&amp;nbsp;is missing a semi-colon, and that may be why it doesn't work. So,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/287036"&gt;@karthik18&lt;/a&gt;&amp;nbsp;please examine your code carefully for a place where you need a semi-colon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, this still doesn't produce a sum or a count, it produces a "count" where the first record in each group is always 0.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Mar 2021 18:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Get-distinct-group-wise-summary-in-SAS-like-pivot-table/m-p/728850#M226796</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-03-24T18:29:27Z</dc:date>
    </item>
  </channel>
</rss>

