<?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: Summary Column for Text Data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834968#M330047</link>
    <description>Thank you for the quick solution. It's working exactly as I need. Sorry about not including the data properly. This was my first question and I thought it was be cleaner for people to see with the formatting but now I know for the future. Thanks again!</description>
    <pubDate>Fri, 23 Sep 2022 20:22:21 GMT</pubDate>
    <dc:creator>Cheesiepoof05</dc:creator>
    <dc:date>2022-09-23T20:22:21Z</dc:date>
    <item>
      <title>Summary Column for Text Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834949#M330043</link>
      <description>&lt;P&gt;I'm using SAS Enterprise guide and switching over from Hyperion Interactive Reporting.&amp;nbsp; I have two data columns that I'm trying to create a summary column of all the unique responses from another column.&amp;nbsp; In the example below I am trying to create the "Colors_By_Animal" column where all of the unique options of colors per animal are rolled together and separated by commas in a third column.&amp;nbsp; Duplicate colors per animal are only shown once and blanks are ignored.&amp;nbsp; Either option of adding the column in with all the data or creating a summary table with just one line per animal would work for me.&amp;nbsp; Any ideas?&amp;nbsp; Please and Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cheesiepoof05_0-1663960410995.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75547iAB97CE50DEC33BBA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cheesiepoof05_0-1663960410995.png" alt="Cheesiepoof05_0-1663960410995.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 19:17:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834949#M330043</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2022-09-23T19:17:10Z</dc:date>
    </item>
    <item>
      <title>Re: Summary Column for Text Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834956#M330045</link>
      <description>&lt;P&gt;Here are two different methods outlined for solving this type of problem.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/d583cfa992bf56da51d435165b07e96a" target="_blank"&gt;https://gist.github.com/statgeek/d583cfa992bf56da51d435165b07e96a&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
    infile cards dlm='09'x;
    input OrgID Product $   States $;
    cards;
1   football    DC
1   football    VA
1   football    MD
2   football    CA
3   football    NV
3   football    CA
;
run;

*Sort - required for both options;
proc sort data=have;
    by orgID;
run;

**********************************************************************;
*Use RETAIN and BY group processing to combine the information;
**********************************************************************;
data want_option1;
    set have;
    by orgID;
    length combined $100.;
    retain combined;

    if first.orgID then
        combined=states;
    else
        combined=catx(', ', combined, states);

    if last.orgID then
        output;
run;

**********************************************************************;
*Transpose it to a wide format and then combine into a single field;
**********************************************************************;
proc transpose data=have out=wide prefix=state_;
    by orgID;
    var states;
run;

data want_option2;
    set wide;
    length combined $100.;
    combined=catx(', ', of state_:);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;FYI - if you provide images and people want to help answer your question with code that is tested, they would have to type out your data manually. Instead provide data at minimum as text, preferably as a data step if possible.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/434710"&gt;@Cheesiepoof05&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm using SAS Enterprise guide and switching over from Hyperion Interactive Reporting.&amp;nbsp; I have two data columns that I'm trying to create a summary column of all the unique responses from another column.&amp;nbsp; In the example below I am trying to create the "Colors_By_Animal" column where all of the unique options of colors per animal are rolled together and separated by commas in a third column.&amp;nbsp; Duplicate colors per animal are only shown once and blanks are ignored.&amp;nbsp; Either option of adding the column in with all the data or creating a summary table with just one line per animal would work for me.&amp;nbsp; Any ideas?&amp;nbsp; Please and Thank you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cheesiepoof05_0-1663960410995.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/75547iAB97CE50DEC33BBA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cheesiepoof05_0-1663960410995.png" alt="Cheesiepoof05_0-1663960410995.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2022 19:23:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834956#M330045</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-09-23T19:23:00Z</dc:date>
    </item>
    <item>
      <title>Re: Summary Column for Text Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834968#M330047</link>
      <description>Thank you for the quick solution. It's working exactly as I need. Sorry about not including the data properly. This was my first question and I thought it was be cleaner for people to see with the formatting but now I know for the future. Thanks again!</description>
      <pubDate>Fri, 23 Sep 2022 20:22:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834968#M330047</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2022-09-23T20:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: Summary Column for Text Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834970#M330049</link>
      <description>I'm using option 1 and just realized I'm getting duplicates if there was more than one of the same color. IE for bears, I'm getting two instances of black in the list.&lt;BR /&gt;&lt;BR /&gt;Bears Black, Black, Brown, Red</description>
      <pubDate>Fri, 23 Sep 2022 20:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834970#M330049</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2022-09-23T20:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Summary Column for Text Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834972#M330050</link>
      <description>&lt;P&gt;You can add a step before combining to remove duplicates:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=have out=noduplicates nodupkey;
by animal individual_color;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Or another method:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Sort - required for both options;
proc sort data=have;
    by orgID states;
run;

**********************************************************************;
*Use RETAIN and BY group processing to combine the information;
**********************************************************************;
data want_option1;
    set have;
    by orgID;
    length combined $100.;
    retain combined;

    if first.orgID then
        combined=states;
    else if first.states then 
         combined=catx(', ', combined, states);

    if last.orgID then
        output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 23 Sep 2022 20:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834972#M330050</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-09-23T20:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: Summary Column for Text Data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834975#M330052</link>
      <description>Thank you</description>
      <pubDate>Fri, 23 Sep 2022 20:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Summary-Column-for-Text-Data/m-p/834975#M330052</guid>
      <dc:creator>Cheesiepoof05</dc:creator>
      <dc:date>2022-09-23T20:48:53Z</dc:date>
    </item>
  </channel>
</rss>

