<?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 Distinct query in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Distinct-query/m-p/859905#M37973</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am trying to find the distinct number of debt_code. In my table, I have a column name ad_type. When I use the distinct code, it gives me debt_code with distinct ad_type. So, the debt_code is repeated and I want just the distinct number of debt_code. I am using the below code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table No_AP_SP_address as 
select distinct a.*,
b.ad_type
from Trace_Accounts as a
inner join p2scflow.addressee b on a.debt_code = b.debt_code
where ad_type not in ('AP','SA') 
group by a.debt_code;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;data Test; &lt;BR /&gt;infile datalines dsd truncover; &lt;BR /&gt;input rep_code debt_code ad_type; &lt;BR /&gt;datalines; &lt;BR /&gt;122 100001833 DB&lt;BR /&gt;122 100001833 XD&lt;BR /&gt;168 100003144 DB&lt;BR /&gt;168 100003144 XD&lt;BR /&gt;168 100003730 DB; &lt;BR /&gt;run; &lt;BR /&gt;Can you please suggest?&lt;/P&gt;</description>
    <pubDate>Tue, 21 Feb 2023 12:00:44 GMT</pubDate>
    <dc:creator>Sandeep77</dc:creator>
    <dc:date>2023-02-21T12:00:44Z</dc:date>
    <item>
      <title>Distinct query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Distinct-query/m-p/859905#M37973</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am trying to find the distinct number of debt_code. In my table, I have a column name ad_type. When I use the distinct code, it gives me debt_code with distinct ad_type. So, the debt_code is repeated and I want just the distinct number of debt_code. I am using the below code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Proc sql;
create table No_AP_SP_address as 
select distinct a.*,
b.ad_type
from Trace_Accounts as a
inner join p2scflow.addressee b on a.debt_code = b.debt_code
where ad_type not in ('AP','SA') 
group by a.debt_code;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;data Test; &lt;BR /&gt;infile datalines dsd truncover; &lt;BR /&gt;input rep_code debt_code ad_type; &lt;BR /&gt;datalines; &lt;BR /&gt;122 100001833 DB&lt;BR /&gt;122 100001833 XD&lt;BR /&gt;168 100003144 DB&lt;BR /&gt;168 100003144 XD&lt;BR /&gt;168 100003730 DB; &lt;BR /&gt;run; &lt;BR /&gt;Can you please suggest?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2023 12:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Distinct-query/m-p/859905#M37973</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-02-21T12:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct query</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Distinct-query/m-p/859907#M37974</link>
      <description>&lt;P&gt;In SQL, you can get the distinct values via&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
     create table distinct_values 
     as select distinct debt_code as distinct_debt_code_values
     from your_dataset;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or if you just want the number of distinct values, you would use:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
     create table number_distinct_values 
     as select count(distinct debt_code) as distinct_debt_code_values
     from your_dataset;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 21 Feb 2023 13:16:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Distinct-query/m-p/859907#M37974</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-02-21T13:16:24Z</dc:date>
    </item>
  </channel>
</rss>

