<?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 Dealing with Duplicates with Proc Freq in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402928#M97909</link>
    <description>&lt;P&gt;I have a dataset that I created from merging two different datasets by ID number. It resembles something like this;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N2&lt;/P&gt;&lt;P&gt;1232&amp;nbsp; KRAS&amp;nbsp; &amp;nbsp;TIR&lt;/P&gt;&lt;P&gt;1232&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;KRAS&amp;nbsp; &amp;nbsp;EGF&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1111&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;KRAS&amp;nbsp; &amp;nbsp;MET&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1111&amp;nbsp; EGF&amp;nbsp; &amp;nbsp; &amp;nbsp;PTEN&lt;/P&gt;&lt;P&gt;1111&amp;nbsp; EGF&amp;nbsp; &amp;nbsp; &amp;nbsp;PTEN&lt;/P&gt;&lt;P&gt;2342&amp;nbsp; PTEN&amp;nbsp; &amp;nbsp;LKR&lt;/P&gt;&lt;P&gt;2323&amp;nbsp; ERK&amp;nbsp; &amp;nbsp; &amp;nbsp;MET&lt;/P&gt;&lt;P&gt;2323&amp;nbsp; MET&amp;nbsp; &amp;nbsp; TER&lt;/P&gt;&lt;P&gt;2222&amp;nbsp; MET&amp;nbsp; &amp;nbsp; REK&lt;/P&gt;&lt;P&gt;2222&amp;nbsp; MET&amp;nbsp; &amp;nbsp; MET&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, they're are many duplicates of each ID number and N and N2, so my issue is I'd like to find out how many unique&amp;nbsp;observations are there through proc freq. So for ID 1232, it would count KRAS only once and for ID 1111 it would count EGF and PTEN only one as well. Is there anyway to do this through Proc freq? Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 10 Oct 2017 19:49:56 GMT</pubDate>
    <dc:creator>kmardinian</dc:creator>
    <dc:date>2017-10-10T19:49:56Z</dc:date>
    <item>
      <title>Dealing with Duplicate observations with Proc Freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402930#M97892</link>
      <description>&lt;P&gt;I have a dataset that I created from merging two different datasets by ID number. It resembles something like this;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N2&lt;/P&gt;&lt;P&gt;1232&amp;nbsp; KRAS&amp;nbsp; &amp;nbsp;TIR&lt;/P&gt;&lt;P&gt;1232&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;KRAS&amp;nbsp; &amp;nbsp;EGF&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1111&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;KRAS&amp;nbsp; &amp;nbsp;MET&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1111&amp;nbsp; EGF&amp;nbsp; &amp;nbsp; &amp;nbsp;PTEN&lt;/P&gt;&lt;P&gt;1111&amp;nbsp; EGF&amp;nbsp; &amp;nbsp; &amp;nbsp;PTEN&lt;/P&gt;&lt;P&gt;2342&amp;nbsp; PTEN&amp;nbsp; &amp;nbsp;LKR&lt;/P&gt;&lt;P&gt;2323&amp;nbsp; ERK&amp;nbsp; &amp;nbsp; &amp;nbsp;MET&lt;/P&gt;&lt;P&gt;2323&amp;nbsp; MET&amp;nbsp; &amp;nbsp; TER&lt;/P&gt;&lt;P&gt;2222&amp;nbsp; MET&amp;nbsp; &amp;nbsp; REK&lt;/P&gt;&lt;P&gt;2222&amp;nbsp; MET&amp;nbsp; &amp;nbsp; MET&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, they're are many duplicates of each ID number and N and N2, so my issue is I'd like to find out how many unique&amp;nbsp;observations are there through proc freq. So for ID 1232, it would count KRAS only once and for ID 1111 it would count EGF and PTEN only one as well. Is there anyway to do this through Proc freq? Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 19:51:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402930#M97892</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T19:51:31Z</dc:date>
    </item>
    <item>
      <title>Dealing with Duplicates with Proc Freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402928#M97909</link>
      <description>&lt;P&gt;I have a dataset that I created from merging two different datasets by ID number. It resembles something like this;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ID&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N2&lt;/P&gt;&lt;P&gt;1232&amp;nbsp; KRAS&amp;nbsp; &amp;nbsp;TIR&lt;/P&gt;&lt;P&gt;1232&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;KRAS&amp;nbsp; &amp;nbsp;EGF&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1111&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;KRAS&amp;nbsp; &amp;nbsp;MET&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1111&amp;nbsp; EGF&amp;nbsp; &amp;nbsp; &amp;nbsp;PTEN&lt;/P&gt;&lt;P&gt;1111&amp;nbsp; EGF&amp;nbsp; &amp;nbsp; &amp;nbsp;PTEN&lt;/P&gt;&lt;P&gt;2342&amp;nbsp; PTEN&amp;nbsp; &amp;nbsp;LKR&lt;/P&gt;&lt;P&gt;2323&amp;nbsp; ERK&amp;nbsp; &amp;nbsp; &amp;nbsp;MET&lt;/P&gt;&lt;P&gt;2323&amp;nbsp; MET&amp;nbsp; &amp;nbsp; TER&lt;/P&gt;&lt;P&gt;2222&amp;nbsp; MET&amp;nbsp; &amp;nbsp; REK&lt;/P&gt;&lt;P&gt;2222&amp;nbsp; MET&amp;nbsp; &amp;nbsp; MET&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfortunately, they're are many duplicates of each ID number and N and N2, so my issue is I'd like to find out how many unique&amp;nbsp;observations are there through proc freq. So for ID 1232, it would count KRAS only once and for ID 1111 it would count EGF and PTEN only one as well. Is there anyway to do this through Proc freq? Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 19:49:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402928#M97909</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T19:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Duplicate observations with Proc Freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402938#M97898</link>
      <description>&lt;P&gt;Assuming the records are grouped by ID, even though not by ascending or descending ID, you can have a DATA step read in your data,&amp;nbsp; BY ID NOTSORTED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Keep a long character variable N_LIST, which starts out each ID as blank (e.g. at first.id), and then accepts N and N2 values if and only if they are not already in N_LIst, inserting them one at a time as space-separated values (see the CATX function).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At the end of the ID, use the COUNTW function to count the number of space separated words (N_ITEMS) in N_LIST, and output the result with 3 variables: ID N_LIST and N_ITEMS.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 20:11:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402938#M97898</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-10T20:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Duplicate observations with Proc Freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402943#M97900</link>
      <description>&lt;P&gt;Hi mkeintz,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;That sounds like it would work perfectly, do you think you could provide me with sample code to see how SAS likes it to be wrriten out?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 20:16:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402943#M97900</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T20:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Duplicate observations with Proc Freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402950#M97902</link>
      <description>&lt;P&gt;Start out by created N_LIST, without removing duplicates&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have;
  by id notsorted;

  length n_list $40;
  retain n_list;

  if first.id then &lt;EM&gt;&lt;STRONG&gt;blank-out-N_LIST&lt;/STRONG&gt;&lt;/EM&gt;
  if &lt;EM&gt;&lt;STRONG&gt;?? test of N vs N_list???&lt;/STRONG&gt;&lt;/EM&gt; then n_list=catx(' ',n_list,N);
  if &lt;EM&gt;&lt;STRONG&gt;?? test of N2 vs N_list???&lt;/STRONG&gt;&lt;/EM&gt; then n_list=catx(' ',n_list,N2);

  if last.id;
  N_items=  &lt;EM&gt;&lt;STRONG&gt;some-function-of&lt;/STRONG&gt;&lt;/EM&gt;(N_list);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I leave it to you to&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;figure out how to blank out N_LIST&lt;/LI&gt;
&lt;LI&gt;determine the IF tests, which essentially test whether the current N (or N2) is not yet entered in N_LIST&lt;/LI&gt;
&lt;LI&gt;get the function for counting space-separated word in N_LIST&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;For #2 and #3 take a look at &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p0w6napahk6x0an0z2dzozh2ouzm.htm" target="_self"&gt;SAS Functions and Call Routines by Category&lt;/A&gt;.&amp;nbsp; Check the &lt;EM&gt;&lt;STRONG&gt;character&lt;/STRONG&gt;&lt;/EM&gt; category&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 20:34:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402950#M97902</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2017-10-10T20:34:17Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Duplicate observations with Proc Freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402962#M97904</link>
      <description>&lt;P&gt;Thank you so much, this has been super helpful!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 21:26:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402962#M97904</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T21:26:13Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Duplicates with Proc Freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402964#M97910</link>
      <description>&lt;P&gt;Please show what the counts you may be wanting are for that example data.&lt;/P&gt;
&lt;P&gt;It sounds like you might be wanting to count occurrences for the same value in different variables but we need to know exactly what you expect.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 21:33:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402964#M97910</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-10T21:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dealing with Duplicates with Proc Freq</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402974#M97911</link>
      <description>&lt;P&gt;Sorry, I seem to have posted this twice, someone was able to direct me in the right direction. Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2017 22:33:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dealing-with-Duplicate-observations-with-Proc-Freq/m-p/402974#M97911</guid>
      <dc:creator>kmardinian</dc:creator>
      <dc:date>2017-10-10T22:33:14Z</dc:date>
    </item>
  </channel>
</rss>

