<?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: Unique value count by variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711089#M218985</link>
    <description>&lt;P&gt;There you go.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transpose if you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Result $ PID treatment $;
datalines;
Yes 1 T
No 1 T
Yes 1 T
Yes 1 O
No 2 R
Yes 2 R
Yes 2 O
Yes 3 T
Yes 3 T
Yes 3 T
Yes 3 O
;

proc sql;
   create table want as
   select treatment,
          count(distinct PID) as count
   from have
   group by treatment;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Jan 2021 13:50:05 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-01-13T13:50:05Z</dc:date>
    <item>
      <title>Unique value count by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711073#M218976</link>
      <description>Data have&lt;BR /&gt;Result PID treatment&lt;BR /&gt;Yes 1 T&lt;BR /&gt;No 1 T&lt;BR /&gt;Yes 1 T&lt;BR /&gt;Yes 1 O&lt;BR /&gt;No 2 R&lt;BR /&gt;Yes 2 R&lt;BR /&gt;Yes 2 O&lt;BR /&gt;Yes 3 T&lt;BR /&gt;Yes 3 T&lt;BR /&gt;Yes 3 T&lt;BR /&gt;Yes 3 O&lt;BR /&gt;Result want count&lt;BR /&gt;T R O&lt;BR /&gt;2 1 3&lt;BR /&gt;&lt;BR /&gt;Thanka in advance</description>
      <pubDate>Wed, 13 Jan 2021 13:25:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711073#M218976</guid>
      <dc:creator>jay_bhavsar</dc:creator>
      <dc:date>2021-01-13T13:25:10Z</dc:date>
    </item>
    <item>
      <title>Re: Unique value count by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711076#M218979</link>
      <description>&lt;P&gt;WIll this help:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/sasdummy/2013/10/16/about-cardinality/" target="_blank"&gt;Your data ain't good looking, but it has a nice cardinality - The SAS Dummy&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt;, I still laugh at the song lyrics in this article.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 13:31:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711076#M218979</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-01-13T13:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unique value count by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711089#M218985</link>
      <description>&lt;P&gt;There you go.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Transpose if you want&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input Result $ PID treatment $;
datalines;
Yes 1 T
No 1 T
Yes 1 T
Yes 1 O
No 2 R
Yes 2 R
Yes 2 O
Yes 3 T
Yes 3 T
Yes 3 T
Yes 3 O
;

proc sql;
   create table want as
   select treatment,
          count(distinct PID) as count
   from have
   group by treatment;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jan 2021 13:50:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711089#M218985</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-13T13:50:05Z</dc:date>
    </item>
    <item>
      <title>Re: Unique value count by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711166#M219018</link>
      <description>&lt;P&gt;Do you want a data set for manipulation or a report people read?&lt;/P&gt;
&lt;P&gt;If you don't mind a vertical report the Nlevels option in Proc Freq may suit.&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;proc freq data=sashelp.class nlevels;&lt;BR /&gt;   ods output nlevels=work.levels;&lt;BR /&gt;   ods select nlevels;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;Which if you have MISSING values will also have a summary involving those n the work.nlevels data set created. If you don't like the vertical layout you could transpose the work.levels, or write a report to use the work.levels.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jan 2021 15:53:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711166#M219018</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-01-13T15:53:46Z</dc:date>
    </item>
    <item>
      <title>Re: Unique value count by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711825#M219334</link>
      <description>Dear PeterClemmensen,&lt;BR /&gt;Thanks for your answer. your SQL giving me the result, but one more thing i want to add the i only want to consider yes from result variable. so i added onw more patient. Then how to calculate the count?&lt;BR /&gt;data have;&lt;BR /&gt;input Result $ PID treatment $;&lt;BR /&gt;datalines;&lt;BR /&gt;Yes 1 T&lt;BR /&gt;No 1 T&lt;BR /&gt;Yes 1 T&lt;BR /&gt;Yes 1 O&lt;BR /&gt;No 2 R&lt;BR /&gt;Yes 2 R&lt;BR /&gt;Yes 2 O&lt;BR /&gt;Yes 3 T&lt;BR /&gt;Yes 3 T&lt;BR /&gt;Yes 3 T&lt;BR /&gt;Yes 3 O&lt;BR /&gt;No 4 R&lt;BR /&gt;No 4 R&lt;BR /&gt;;</description>
      <pubDate>Sat, 16 Jan 2021 04:33:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711825#M219334</guid>
      <dc:creator>jay_bhavsar</dc:creator>
      <dc:date>2021-01-16T04:33:33Z</dc:date>
    </item>
    <item>
      <title>Re: Unique value count by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711828#M219336</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table want as
   select treatment,
          count(distinct PID) as count
   from have
   where Result = 'Yes'
   group by treatment;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 16 Jan 2021 06:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711828#M219336</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-01-16T06:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unique value count by variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711843#M219343</link>
      <description>It worked...&lt;BR /&gt;I learned new thing today. Thank you so much for your support.</description>
      <pubDate>Sat, 16 Jan 2021 11:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unique-value-count-by-variable/m-p/711843#M219343</guid>
      <dc:creator>jay_bhavsar</dc:creator>
      <dc:date>2021-01-16T11:13:44Z</dc:date>
    </item>
  </channel>
</rss>

