<?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: Looking for distinct name by a variable in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875431#M38847</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *,count(distinct catx(' ',dr_inits,dr_name)) as n_name
 from name
  group by icustomerid ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 12 May 2023 11:39:49 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2023-05-12T11:39:49Z</dc:date>
    <item>
      <title>Looking for distinct name by a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875010#M38838</link>
      <description>&lt;P&gt;&amp;nbsp;Hi all,&lt;/P&gt;
&lt;P&gt;I have a dataset with icustomerid, debt_code and names. I am trying to find how many unique icustomerid have different names. So I am counting distinct names by icustomerid. But I am not sure the right approach for this. Can you please suggest what can I do?&lt;/P&gt;
&lt;TABLE width="480"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="106"&gt;icustomerid&lt;/TD&gt;
&lt;TD width="113"&gt;debt_code&lt;/TD&gt;
&lt;TD width="69"&gt;rep_code&lt;/TD&gt;
&lt;TD width="64"&gt;dr_inits&lt;/TD&gt;
&lt;TD width="128"&gt;dr_name&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;48196&lt;/TD&gt;
&lt;TD&gt;367762168&lt;/TD&gt;
&lt;TD&gt;131&lt;/TD&gt;
&lt;TD&gt;Tami&lt;/TD&gt;
&lt;TD&gt;Baker&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;48196&lt;/TD&gt;
&lt;TD&gt;337656029&lt;/TD&gt;
&lt;TD&gt;131&lt;/TD&gt;
&lt;TD&gt;Tami&lt;/TD&gt;
&lt;TD&gt;Baker&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;48196&lt;/TD&gt;
&lt;TD&gt;302678693&lt;/TD&gt;
&lt;TD&gt;131&lt;/TD&gt;
&lt;TD&gt;Tami&lt;/TD&gt;
&lt;TD&gt;Baker&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data name;
input icustomerid	debt_code	rep_code	dr_inits	dr_name;
datalines ;
48196	367762168	131	Tami	Baker
48196	337656029	131	Tami	Baker
48196	302678693	131	Tami	Baker;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 May 2023 16:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875010#M38838</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-10T16:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for distinct name by a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875011#M38839</link>
      <description>Please make a more representative example. Include a few different scenarios, specifically ones that may be problematic. &lt;BR /&gt;What do you expect as output from this data?</description>
      <pubDate>Wed, 10 May 2023 16:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875011#M38839</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2023-05-10T16:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for distinct name by a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875020#M38840</link>
      <description>&lt;P&gt;No need to show us the "Excel"-like table. The SAS code is sufficient. However, as I have mentioned to you many times now, the code you have presented doesn't work. Please test your code before providing it to us to make sure it works (and please fix this code).&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 16:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875020#M38840</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-05-10T16:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for distinct name by a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875184#M38841</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data name;
infile cards expandtabs;
input icustomerid debt_code rep_code dr_inits $ dr_name $;
datalines ;
48196 367762168 131 Tami Baker
48196 337656029 131 Tami Baker
48196 302678693 131 Tami Baker
;
run;

proc sql;
create table want as
select icustomerid,count(distinct dr_name) as n_name
 from name
  group by icustomerid ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 May 2023 11:51:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875184#M38841</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-05-11T11:51:33Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for distinct name by a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875410#M38845</link>
      <description>&lt;P&gt;Apologies for that. I have changed the code for the dataset and now it works fine. I am looking for output where it shows count distinct names by icustomerid. So the icustomerid no.&amp;nbsp;&lt;CODE class=" language-sas"&gt;200914 should&amp;nbsp;be&amp;nbsp;1&amp;nbsp; as the icustomerid is same and name is also same. Also, the&amp;nbsp;count&amp;nbsp;for&amp;nbsp;surname&amp;nbsp;would&amp;nbsp;be&amp;nbsp;1.&amp;nbsp; &lt;/CODE&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA Name;
INPUT customerid debt_code rep_code dr_inits $ dr_name $ dr_address1 $ dr_address2 $ dr_address3 $;
CARDS;
186071 423212679 131 Natalie Perrin 12 Pirbright Close Bilston West Midlands
190034 386693311 131 Vancere Irish 45 Mere Road Birmingham
200914 148062417 131 Nyaradzai Maranduie 24 Earl Rise London
200914 10150751 131 Nyaradzai Maranduie 24 Earl Rise London
204413 269064234 131 Claire Buchanan 77 Cambridge Road Bootle
;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 May 2023 08:42:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875410#M38845</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-12T08:42:19Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for distinct name by a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875411#M38846</link>
      <description>Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;. It worked. Your code with table want gets the correct information but can you let me know what can I do to add all the variables from the previous table as the code only shows icustomerid and n_name variable. I want it to include all the variables from previous table. Also, is it possible to have distinct Dr_inits and Dr_name? I want both of them distinct so that the name and surname both matches exactly. Thanks</description>
      <pubDate>Fri, 12 May 2023 08:49:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875411#M38846</guid>
      <dc:creator>Sandeep77</dc:creator>
      <dc:date>2023-05-12T08:49:26Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for distinct name by a variable</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875431#M38847</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select *,count(distinct catx(' ',dr_inits,dr_name)) as n_name
 from name
  group by icustomerid ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 12 May 2023 11:39:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Looking-for-distinct-name-by-a-variable/m-p/875431#M38847</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2023-05-12T11:39:49Z</dc:date>
    </item>
  </channel>
</rss>

