<?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: Count Unique Values by Row and Use Values as Column Names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Count-Unique-Values-by-Row-and-Use-Values-as-Column-Names/m-p/784448#M250337</link>
    <description>&lt;P&gt;It already does that, it's in the WANT data set. Change the name if you want it to have a different name.&amp;nbsp;&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/408985"&gt;@cobba&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;That is what I'm looking for. Thank you. How do I make the report a table?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Dec 2021 02:58:40 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-12-07T02:58:40Z</dc:date>
    <item>
      <title>Count Unique Values by Row and Use Values as Column Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Unique-Values-by-Row-and-Use-Values-as-Column-Names/m-p/784428#M250327</link>
      <description>&lt;P&gt;Using SAS EG v7.1&lt;/P&gt;&lt;P&gt;I have the following data where an event is represented by an ID and any number of codes (always strings) can be applied to each event.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data have;
    input id$ code$ @@;
    datalines;
    aa x1 aa x1 aa x2
    bb x1 bb y1 bb y1 bb z2 bb z4
    cc x1 cc x2 cc y1 cc x1 cc x1 cc q1
    dd z2 dd z2 dd z2 dd q1
    ;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Episode IDs and Codes are always strings but can be of varying lengths.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The data below is what I want. Where the unique codes make up the column headings and the count is performed for each ID.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 561px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66449iCA9B81C5D5C04322/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 00:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Unique-Values-by-Row-and-Use-Values-as-Column-Names/m-p/784428#M250327</guid>
      <dc:creator>cobba</dc:creator>
      <dc:date>2021-12-07T00:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Count Unique Values by Row and Use Values as Column Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Unique-Values-by-Row-and-Use-Values-as-Column-Names/m-p/784429#M250328</link>
      <description>&lt;P&gt;Does this work for you?&lt;BR /&gt;Do you need a table or report?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=have;
table id*code / out=id_counts norow nocol nopercent sparse;
run;

proc transpose data=id_counts out=want (drop = _name_ _label_);
by id;
id code;
var count;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/408985"&gt;@cobba&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Using SAS EG v7.1&lt;/P&gt;
&lt;P&gt;I have the following data where an event is represented by an ID and any number of codes (always strings) can be applied to each event.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;data have;
    input id$ code$ @@;
    datalines;
    aa x1 aa x1 aa x2
    bb x1 bb y1 bb y1 bb z2 bb z4
    cc x1 cc x2 cc y1 cc x1 cc x1 cc q1
    dd z2 dd z2 dd z2 dd q1
    ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Episode IDs and Codes are always strings but can be of varying lengths.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The data below is what I want. Where the unique codes make up the column headings and the count is performed for each ID.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 561px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66449iCA9B81C5D5C04322/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 01:15:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Unique-Values-by-Row-and-Use-Values-as-Column-Names/m-p/784429#M250328</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-07T01:15:26Z</dc:date>
    </item>
    <item>
      <title>Re: Count Unique Values by Row and Use Values as Column Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Unique-Values-by-Row-and-Use-Values-as-Column-Names/m-p/784443#M250334</link>
      <description>&lt;P&gt;That is what I'm looking for. Thank you. How do I make the report a table?&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 02:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Unique-Values-by-Row-and-Use-Values-as-Column-Names/m-p/784443#M250334</guid>
      <dc:creator>cobba</dc:creator>
      <dc:date>2021-12-07T02:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Count Unique Values by Row and Use Values as Column Names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Count-Unique-Values-by-Row-and-Use-Values-as-Column-Names/m-p/784448#M250337</link>
      <description>&lt;P&gt;It already does that, it's in the WANT data set. Change the name if you want it to have a different name.&amp;nbsp;&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/408985"&gt;@cobba&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;That is what I'm looking for. Thank you. How do I make the report a table?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Dec 2021 02:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Count-Unique-Values-by-Row-and-Use-Values-as-Column-Names/m-p/784448#M250337</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-07T02:58:40Z</dc:date>
    </item>
  </channel>
</rss>

