<?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: Proc SQL Select Distinct in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/390172#M277447</link>
    <description>&lt;P&gt;It worked!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Aug 2017 10:22:49 GMT</pubDate>
    <dc:creator>eugenia67</dc:creator>
    <dc:date>2017-08-23T10:22:49Z</dc:date>
    <item>
      <title>Proc SQL Select Distinct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/388892#M277443</link>
      <description>&lt;P&gt;Hello everyone,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a &amp;nbsp;Proc sql select distinct programm on SAS that counts the number of code (one code desginates individuals pertaining to the same group, so code 5 designates all individuals in group 5) by company:&amp;nbsp;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE nbcode AS&lt;BR /&gt;SELECT DISTINCT code, COUNT(code) AS&amp;nbsp;numbercode&lt;BR /&gt;FROM work.example&lt;BR /&gt;GROUP BY COMP;&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It gives me something like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;code &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nombrecode&lt;/P&gt;&lt;P&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&lt;/P&gt;&lt;P&gt;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 10&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;5 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6&lt;/P&gt;&lt;P&gt;6 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;That means that; for example, 6 individuals of group 5 are in one company and one individual of group 5 is in a company alone.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to know how to add to this table the company identifier (designated by the variable COMP). I thought the by comp would put automatically the comp identifier in a column to the right, but i was wrong, and i can not manage to do this ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Could you help me please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;More generally, how to add other variables we wish to have in a select distinct table?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you very much for your help,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eugenie&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:16:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/388892#M277443</guid>
      <dc:creator>eugenia67</dc:creator>
      <dc:date>2017-08-17T17:16:58Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Select Distinct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/388897#M277444</link>
      <description>&lt;P&gt;Post sample data that shows what you have and what you want.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 17:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/388897#M277444</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-08-17T17:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Select Distinct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/388940#M277445</link>
      <description>&lt;P&gt;Did you try putting the Comp variable on the select statement?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2017 19:17:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/388940#M277445</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-08-17T19:17:24Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Select Distinct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/389027#M277446</link>
      <description>&lt;P&gt;If you want a variable in the output then it needs to be listed in the variable list part of the SELECT statement.&lt;/P&gt;
&lt;P&gt;Do you want the list of CODE values nested inside the list of COMP values?&lt;/P&gt;
&lt;P&gt;If you want to count how many times each COMP x CODE combination appears you would want this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table nbcode as
  select comp
       , code
       , count(*) as nobs
  from work.example
  group by 1,2
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you wanted to count how many distinct value of CODE appear within each value of COMP you would want this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table nbcode as
  select comp
       , count(distinct code) as ncodes
  from work.example
  group by 1
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 03:26:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/389027#M277446</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-08-18T03:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc SQL Select Distinct</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/390172#M277447</link>
      <description>&lt;P&gt;It worked!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 10:22:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-SQL-Select-Distinct/m-p/390172#M277447</guid>
      <dc:creator>eugenia67</dc:creator>
      <dc:date>2017-08-23T10:22:49Z</dc:date>
    </item>
  </channel>
</rss>

