<?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: Duplicate values are removed without consent. in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403797#M3699</link>
    <description>&lt;P&gt;It does not look like you need to do a join.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table claims_details as
select id as claimid
     , policynumber
     , productc
     , claimnumber
     , claimnotifieddate
     , status
     , occurencedate
     , losstype
     , totalpaidamount
     , intimateddate
     , dateadmitted
     , datedischarged
     , dateapproved
     , lossdescription
     , transactionnumber
     , approvedamount
     , lossdescriptioncode
     , claimentrydate
     , causeofeventcode
     , closedate
     , lossdate
     , illnesscode
     , illness
from ods_claim
where status in ('Fully Paid')
  and policynumber in (select distinct policynumber from ch_p02_source_5)
;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Oct 2017 05:21:21 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2017-10-13T05:21:21Z</dc:date>
    <item>
      <title>Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403442#M3670</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;For some reason, my codes keep on removing the duplicate records which I intended to keep.&lt;BR /&gt;The scenario is, I have 2 sets of tables, by using a column(POLICYNUMBER) I would join them together. Both table would contain POLICYNUMBERs and there are some records which are duplicates. After processed by SAS, all the records that fits the requirements of the coding are displayed BUT records that fits the requirements but with duplicate POLICYNUMBER are removed from the final result.&lt;BR /&gt;&lt;BR /&gt;The following is a part of the coding;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE CLAIMS_DETAILS AS&lt;BR /&gt;(&lt;BR /&gt;SELECT ID AS CLAIMID,ODS_CLAIM.POLICYNUMBER,PRODUCTC,CLAIMNUMBER,CLAIMNOTIFIEDDATE,STATUS,OCCURENCEDATE,LOSSTYPE,&lt;BR /&gt;TOTALPAIDAMOUNT,INTIMATEDDATE,DATEADMITTED,DATEDISCHARGED,&lt;BR /&gt;DATEAPPROVED,LOSSDESCRIPTION,TRANSACTIONNUMBER,APPROVEDAMOUNT,&lt;BR /&gt;LOSSDESCRIPTIONCODE,CLAIMENTRYDATE,CAUSEOFEVENTCODE,CLOSEDATE,LOSSDATE,ILLNESSCODE,ILLNESS&lt;/P&gt;&lt;P&gt;FROM ODS_CLAIM, (SELECT DISTINCT(POLICYNUMBER) FROM CH_P02_SOURCE_5) TEMP&lt;BR /&gt;WHERE ODS_CLAIM.POLICYNUMBER=TEMP.POLICYNUMBER&lt;BR /&gt;AND STATUS IN ('Fully Paid')&lt;BR /&gt;);&lt;BR /&gt;QUIT;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Sorry if my explanation is a bit confusing cause I am not really sure how to put it into words.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 04:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403442#M3670</guid>
      <dc:creator>Wken1122</dc:creator>
      <dc:date>2017-10-12T04:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403447#M3671</link>
      <description>&lt;P&gt;Note the word DISTINCT. That will select distinct records. And the WHERE clause may remove them as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Those are where I'd start checking.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 05:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403447#M3671</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-12T05:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403455#M3674</link>
      <description>&lt;P&gt;Oh I am sorry, I made a mistake in explaining the scenario.&lt;BR /&gt;POLICYNUMBER that are duplicates in one table, SOURCE should be removed.&lt;BR /&gt;ALL POLICYNUMBER in the other table should be retained.&lt;BR /&gt;That's why DISTINCT is used.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 06:33:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403455#M3674</guid>
      <dc:creator>Wken1122</dc:creator>
      <dc:date>2017-10-12T06:33:38Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403456#M3675</link>
      <description>&lt;P&gt;In which of the datasets are duplicates found? If only in CH_P02_SOURCE_5, then the distinct clause will remove them.&lt;/P&gt;
&lt;P&gt;Duplicates in ODS_CLAIM will remain, see this short example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data claims;
input pnr $ clid $;
cards;
12345 111
12345 222
56789 333
76477 444
;
run;

data source;
input pnr $;
cards;
12345
12345
56789
56789
;
run;

proc sql;
create table want as
select claims.*
from claims, (select distinct pnr from source) temp
where claims.pnr = temp.pnr
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And stop coding in capitals, that's an eyesore. Shouting at the SAS interpreter isn't necessary &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 06:35:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403456#M3675</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-12T06:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403459#M3676</link>
      <description>&lt;P&gt;the intent was to remove the duplicates from source 5 first then compare with ods_claims.&lt;BR /&gt;So it is ok for ods_claims' data to retain the duplicates but the final result that i got is where ALL the duplicate POLICYNUMBER (from both tables) are removed.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 07:00:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403459#M3676</guid>
      <dc:creator>Wken1122</dc:creator>
      <dc:date>2017-10-12T07:00:45Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403462#M3677</link>
      <description>&lt;P&gt;To verify this, we will need example data that illustrates this behaviour. See &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;How to create a Datastep from a Dataset&lt;/A&gt; for posting example data.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 07:03:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403462#M3677</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-12T07:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403495#M3680</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165226"&gt;@Wken1122&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;I can't see anything in your SQL that would explain what you observe unless your other part in the join condition filters out the records.&lt;/P&gt;
&lt;PRE&gt;... AND STATUS IN ('Fully Paid')&lt;/PRE&gt;
&lt;P&gt;Could this explain the "lost" records? Have you checked if there is more than one record per policynumber with a status of "Fully Paid"?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 11:20:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403495#M3680</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-12T11:20:58Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403602#M3682</link>
      <description>&lt;P&gt;Maybe what you are looking for is a LEFT (or Right) Join on a value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data one;
   input policynumber;
datalines;
1
1
1
2
2
2
3
;
run;

data two;
   input policynumber value;
datalines;
1  345
1  456
1  678
1  2
1  222
2  123
2  444
3  999
3  888
3  777
4  202
;
run;

proc sql;
   create table want as
   select a.*, b.value
   from (select distinct policynumber from one) as a
        left join
        two as b
        on a.policynumber=b.policynumber
   ;
quit;&lt;/PRE&gt;
&lt;P&gt;Notice that values in two for policynumber that don't appear in set one are not in the result and the ones selected from set two only appear once&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Oct 2017 15:49:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403602#M3682</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-12T15:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403749#M3684</link>
      <description>&lt;P&gt;There are 1000+ records(after DISTINCT) that are under the status of FULLY PAID yet only 603 of them are generated at SAS.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 01:48:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403749#M3684</guid>
      <dc:creator>Wken1122</dc:creator>
      <dc:date>2017-10-13T01:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403760#M3685</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165226"&gt;@Wken1122&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;You're using an inner join so the only remaining explanation I'm having is that there are&amp;nbsp;&lt;SPAN&gt;POLICYNUMBER values in the one table which don't exist in the other table.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If variable&amp;nbsp;POLICYNUMBER is character then use &lt;EM&gt;upcase(strip(POLICYNUMBER))&lt;/EM&gt; before you join.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;What you observe must have an explanation in your data. Investigate one of the dropped&amp;nbsp;POLICYNUMBER&amp;nbsp;and check if it really exists in both tables. And if it exists and looks exactly the same in both source tables then also consider non-printable characters - you can remove such characters using the compress() function with the right switches.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...and last but not least: Also "standardize"&amp;nbsp;&lt;EM&gt;fully paid&lt;/EM&gt;:&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;AND upcase(compress(STATUS)) IN ('FULLYPAID')&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Oct 2017 02:30:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403760#M3685</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-13T02:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403780#M3691</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&lt;BR /&gt;I'm sorry, i mistakenly explained the scenario.&lt;BR /&gt;For the SOURCE_5, any duplicates value will be removed while duplicate values on the other table, CLAIMS &lt;STRONG&gt;MUST&lt;/STRONG&gt; be retained.&lt;BR /&gt;&lt;BR /&gt;Also I had already done the checking, from the SOURCE_5 table, exist a one to many relation to the CLAIMS table, where for example, one insurance policy could have several claims. Therefore, all the duplicate POLICYNUMBER on the SOURCE_5 are removed thru the DISTINCT function and the remaining POLICYNUMBER would and could match with more than one POLICYNUMBER on CLAIMS table.&lt;BR /&gt;&lt;BR /&gt;variable POLICYNUMBER is alphanumeric so does it affect anything?&lt;BR /&gt;&lt;BR /&gt;I had try to standardize STATUS but don't seems to change anything.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 03:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403780#M3691</guid>
      <dc:creator>Wken1122</dc:creator>
      <dc:date>2017-10-13T03:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403787#M3694</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165226"&gt;@Wken1122&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&lt;BR /&gt;I'm sorry, i mistakenly explained the scenario.&lt;BR /&gt;For the SOURCE_5, any duplicates value will be removed while duplicate values on the other table, CLAIMS &lt;STRONG&gt;MUST&lt;/STRONG&gt; be retained.&lt;BR /&gt;&lt;BR /&gt;Also I had already done the checking, from the SOURCE_5 table, exist a one to many relation to the CLAIMS table, where for example, one insurance policy could have several claims. Therefore, all the duplicate POLICYNUMBER on the SOURCE_5 are removed thru the DISTINCT function and the remaining POLICYNUMBER would and could match with more than one POLICYNUMBER on CLAIMS table.&lt;BR /&gt;&lt;BR /&gt;variable POLICYNUMBER is alphanumeric so does it affect anything?&lt;BR /&gt;&lt;BR /&gt;I had try to standardize STATUS but don't seems to change anything.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165226"&gt;@Wken1122&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Yes, I understand, you're joining (inner join) two tables with a 1:M relationship. If you "loose" records then it's because there are values for POLICENUMBER in CLAIMS which don't exist in SOURCE_5.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;variable POLICYNUMBER is alphanumeric so does it affect anything?&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then to be on the safe side make sure you strip() or compress() the values as well as uppercase() them BEFORE you use them in the join condition.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 04:00:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403787#M3694</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-13T04:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403788#M3695</link>
      <description>DATA CH_P02_SOURCE_5;&lt;BR /&gt;SET CH_P02_SOURCE_5;&lt;BR /&gt;WHERE COMPRESS(strip(POLICYNUMBER));&lt;BR /&gt;RUN;&lt;BR /&gt;&lt;BR /&gt;Am I using it correctly? If yes then it didn't change a thing...</description>
      <pubDate>Fri, 13 Oct 2017 04:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403788#M3695</guid>
      <dc:creator>Wken1122</dc:creator>
      <dc:date>2017-10-13T04:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403796#M3698</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/165226"&gt;@Wken1122&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;If&amp;nbsp;below doesn't return what you expect then I won't be able to help you any further without actually seeing the data.&lt;/P&gt;
&lt;PRE&gt;WHERE 
  upcase(compress(compress(CLAIM.POLICYNUMBER,,'kw')))=upcase(compress(compress(TEMP.POLICYNUMBER,,'kw')))
  and upcase(compress(compress(STATUS,,'kw')))= 'FULLYPAID'&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Oct 2017 05:00:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403796#M3698</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-13T05:00:09Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403797#M3699</link>
      <description>&lt;P&gt;It does not look like you need to do a join.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table claims_details as
select id as claimid
     , policynumber
     , productc
     , claimnumber
     , claimnotifieddate
     , status
     , occurencedate
     , losstype
     , totalpaidamount
     , intimateddate
     , dateadmitted
     , datedischarged
     , dateapproved
     , lossdescription
     , transactionnumber
     , approvedamount
     , lossdescriptioncode
     , claimentrydate
     , causeofeventcode
     , closedate
     , lossdate
     , illnesscode
     , illness
from ods_claim
where status in ('Fully Paid')
  and policynumber in (select distinct policynumber from ch_p02_source_5)
;
quit;

&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Oct 2017 05:21:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403797#M3699</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-13T05:21:21Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403808#M3700</link>
      <description>&lt;P&gt;Unfortunately, the result is still the same...&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 06:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403808#M3700</guid>
      <dc:creator>Wken1122</dc:creator>
      <dc:date>2017-10-13T06:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403812#M3701</link>
      <description>&lt;P&gt;We are all making guesses here, and then put shots into the dark.&lt;/P&gt;
&lt;P&gt;You HAVE to post example data that illustrates the issue; without that, we won't be able to really help you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just some records from both datasets that show the effect you experience. Use the macro provided in&amp;nbsp;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; to convert your example datasets to data steps that can be posted here.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 06:34:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403812#M3701</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-13T06:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403818#M3702</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;The following is the a sample of the data sets.&lt;BR /&gt;For CH_P02_SOURCE_5, there are too many variables and the records that could match with the sample data for ODS_CLAIM is pretty way back(1000+ rows) so i have narrow it down and only provide the POLICYNUMBER. Hopefully its enough.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;data WORK.POLICYNUMBER;
  
infile datalines dsd truncover;
  
input POLICYNUMBER:$12.;

datalines4;

136838

281600

500035316

500035233

299719

340570

276089

81125
;;;;&lt;/PRE&gt;&lt;PRE&gt;data WORK.ODS_CLAIM;
  
infile datalines dsd truncover;
  
input ID:$19. POLICYNUMBER:$12. PRODUCTC:$3. CLAIMNUMBER:$14. CLAIMNOTIFIEDDATE:DATETIME. STATUS:$30. LOSSDATE:DATETIME. OCCURENCEDATE:DATETIME. LOSSTYPE:$44. TOTALPAIDAMOUNT:BEST12. LOSSDESCRIPTION:$52. INTIMATEDDATE:DATETIME. CLOSEDATE:DATETIME. TRANSACTIONNUMBER:$14. DATEADMITTED:DATETIME. DATEAPPROVED:DATETIME. DATEDISCHARGED:DATETIME. APPROVEDAMOUNT:BEST12. ILLNESSCODE:$5. ILLNESS:$160. LOSSDESCRIPTIONCODE:BEST12. CAUSEOFEVENTCODE:$3. CLAIMENTRYDATE:DATETIME.;

datalines4;

I303-4912889117,203083,EIB,1,30NOV95:00:00:00,Fully Paid,11NOV95:00:00:00,,HOSPITAL BENEFIT,175,,,,,11NOV95:00:00:00,30NOV95:00:00:00,18NOV95:00:00:00,175,101,ANGINA PECTORIS - CHEST PAIN,,,

I303-4912882391,237438,EIB,1,19APR95:00:00:00,Fully Paid,22MAR95:00:00:00,,HOSPITAL BENEFIT,350,,,,,22MAR95:00:00:00,19APR95:00:00:00,29MAR95:00:00:00,350,727,PARASTIC INFECTION,,,

I303-4913303396,276089,EIB,2,08SEP06:00:00:00,Fully Paid,06APR13:00:00:00,,HOSPITAL BENEFIT,3000,,,,,06APR13:00:00:00,08OCT06:00:00:00,06APR24:00:00:00,3000,604,DIABETES MELLITUS,,,

I303-4913389106,276089,EIB,3,07JAN09:00:00:00,Fully Paid,09FEB15:00:00:00,,HOSPITAL BENEFIT,250,,,,,09FEB15:00:00:00,10MAY09:00:00:00,09FEB18:00:00:00,250,113,MYOCARDIAL INFARCTION,,,

I303-4913199216,276089,EIB,1,10DEC04:00:00:00,Fully Paid,04AUG19:00:00:00,,HOSPITAL BENEFIT,200,,,,,04AUG19:00:00:00,10DEC04:00:00:00,04AUG23:00:00:00,200,604,DIABETES MELLITUS,,,

I303-4912889249,279992,EIB,1,02OCT04:00:00:00,Fully Paid,04JAN24:00:00:00,,HOSPITAL BENEFIT,75,,,,,04JAN24:00:00:00,02OCT04:00:00:00,04JAN27:00:00:00,75,423,OTHERS - DIGESTIVE,,,

I303-4912889261,281600,EIB,1,14OCT94:00:00:00,Fully Paid,10FEB94:00:00:00,,HOSPITAL BENEFIT,100,,,,,10FEB94:00:00:00,14OCT94:00:00:00,10JUN94:00:00:00,100,311,HEPATITIS - INFECTIVE &amp;amp; ALCOHOLIC,,,

I303-4912889262,281600,EIB,2,01OCT03:00:00:00,Fully Paid,02DEC18:00:00:00,,HOSPITAL BENEFIT,50,,,,,02DEC18:00:00:00,01OCT03:00:00:00,02DEC20:00:00:00,50,729,"NASAL AILMENTS - SINUSITIES, RHINITIS",,,

I303-4913439139,283895,EIB,3,04APR13:00:00:00,Fully Paid,13FEB25:00:00:00,,HOSPITAL BENEFIT,50,,,,,13FEB25:00:00:00,04OCT13:00:00:00,13FEB27:00:00:00,50,423,OTHERS - DIGESTIVE,,,

I303-4913443756,283895,EIB,4,13MAY29:00:00:00,Fully Paid,13FEB22:00:00:00,,HOSPITAL BENEFIT,75,,,,,13FEB22:00:00:00,06JUL13:00:00:00,13FEB25:00:00:00,75,423,OTHERS - DIGESTIVE,,,
;;;;&lt;/PRE&gt;&lt;P&gt;If its wrong please tell me. I am quite new to this.&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 07:05:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403818#M3702</guid>
      <dc:creator>Wken1122</dc:creator>
      <dc:date>2017-10-13T07:05:39Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403820#M3703</link>
      <description>&lt;P&gt;Some empty lines, but otherwise OK &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I ran this code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data WORK.POLICYNUMBER;
infile datalines dsd truncover;
input POLICYNUMBER:$12.;
datalines4;
136838
281600
500035316
500035233
299719
340570
276089
81125
;;;;
run;

data WORK.ODS_CLAIM;
infile datalines dsd truncover;
input ID:$19. POLICYNUMBER:$12. PRODUCTC:$3. CLAIMNUMBER:$14. CLAIMNOTIFIEDDATE:DATETIME. STATUS:$30. LOSSDATE:DATETIME. OCCURENCEDATE:DATETIME. LOSSTYPE:$44. TOTALPAIDAMOUNT:BEST12. LOSSDESCRIPTION:$52. INTIMATEDDATE:DATETIME. CLOSEDATE:DATETIME. TRANSACTIONNUMBER:$14. DATEADMITTED:DATETIME. DATEAPPROVED:DATETIME. DATEDISCHARGED:DATETIME. APPROVEDAMOUNT:BEST12. ILLNESSCODE:$5. ILLNESS:$160. LOSSDESCRIPTIONCODE:BEST12. CAUSEOFEVENTCODE:$3. CLAIMENTRYDATE:DATETIME.;
datalines4;
I303-4912889117,203083,EIB,1,30NOV95:00:00:00,Fully Paid,11NOV95:00:00:00,,HOSPITAL BENEFIT,175,,,,,11NOV95:00:00:00,30NOV95:00:00:00,18NOV95:00:00:00,175,101,ANGINA PECTORIS - CHEST PAIN,,,
I303-4912882391,237438,EIB,1,19APR95:00:00:00,Fully Paid,22MAR95:00:00:00,,HOSPITAL BENEFIT,350,,,,,22MAR95:00:00:00,19APR95:00:00:00,29MAR95:00:00:00,350,727,PARASTIC INFECTION,,,
I303-4913303396,276089,EIB,2,08SEP06:00:00:00,Fully Paid,06APR13:00:00:00,,HOSPITAL BENEFIT,3000,,,,,06APR13:00:00:00,08OCT06:00:00:00,06APR24:00:00:00,3000,604,DIABETES MELLITUS,,,
I303-4913389106,276089,EIB,3,07JAN09:00:00:00,Fully Paid,09FEB15:00:00:00,,HOSPITAL BENEFIT,250,,,,,09FEB15:00:00:00,10MAY09:00:00:00,09FEB18:00:00:00,250,113,MYOCARDIAL INFARCTION,,,
I303-4913199216,276089,EIB,1,10DEC04:00:00:00,Fully Paid,04AUG19:00:00:00,,HOSPITAL BENEFIT,200,,,,,04AUG19:00:00:00,10DEC04:00:00:00,04AUG23:00:00:00,200,604,DIABETES MELLITUS,,,
I303-4912889249,279992,EIB,1,02OCT04:00:00:00,Fully Paid,04JAN24:00:00:00,,HOSPITAL BENEFIT,75,,,,,04JAN24:00:00:00,02OCT04:00:00:00,04JAN27:00:00:00,75,423,OTHERS - DIGESTIVE,,,
I303-4912889261,281600,EIB,1,14OCT94:00:00:00,Fully Paid,10FEB94:00:00:00,,HOSPITAL BENEFIT,100,,,,,10FEB94:00:00:00,14OCT94:00:00:00,10JUN94:00:00:00,100,311,HEPATITIS - INFECTIVE &amp;amp; ALCOHOLIC,,,
I303-4912889262,281600,EIB,2,01OCT03:00:00:00,Fully Paid,02DEC18:00:00:00,,HOSPITAL BENEFIT,50,,,,,02DEC18:00:00:00,01OCT03:00:00:00,02DEC20:00:00:00,50,729,"NASAL AILMENTS - SINUSITIES, RHINITIS",,,
I303-4913439139,283895,EIB,3,04APR13:00:00:00,Fully Paid,13FEB25:00:00:00,,HOSPITAL BENEFIT,50,,,,,13FEB25:00:00:00,04OCT13:00:00:00,13FEB27:00:00:00,50,423,OTHERS - DIGESTIVE,,,
I303-4913443756,283895,EIB,4,13MAY29:00:00:00,Fully Paid,13FEB22:00:00:00,,HOSPITAL BENEFIT,75,,,,,13FEB22:00:00:00,06JUL13:00:00:00,13FEB25:00:00:00,75,423,OTHERS - DIGESTIVE,,,
;;;;
run;

proc sql;
create table claims_details as
select id as claimid, policynumber
from ods_claim
where status in ('Fully Paid')
  and policynumber in (select distinct policynumber from policynumber)
;
quit;

proc print data=claims_details noobs;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and got this result:&lt;/P&gt;
&lt;PRE&gt;    claimid        POLICYNUMBER

I303-4913303396       276089   
I303-4913389106       276089   
I303-4913199216       276089   
I303-4912889261       281600   
I303-4912889262       281600   
&lt;/PRE&gt;
&lt;P&gt;You can see that no repeats of the policynumber were removed.&lt;/P&gt;
&lt;P&gt;Then I ran your original code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
CREATE TABLE CLAIMS_DETAILS AS
(
SELECT ID AS CLAIMID,ODS_CLAIM.POLICYNUMBER,PRODUCTC,CLAIMNUMBER,CLAIMNOTIFIEDDATE,STATUS,OCCURENCEDATE,LOSSTYPE,
TOTALPAIDAMOUNT,INTIMATEDDATE,DATEADMITTED,DATEDISCHARGED,
DATEAPPROVED,LOSSDESCRIPTION,TRANSACTIONNUMBER,APPROVEDAMOUNT,
LOSSDESCRIPTIONCODE,CLAIMENTRYDATE,CAUSEOFEVENTCODE,CLOSEDATE,LOSSDATE,ILLNESSCODE,ILLNESS

FROM ODS_CLAIM, (SELECT DISTINCT(POLICYNUMBER) FROM policynumber) TEMP
WHERE ODS_CLAIM.POLICYNUMBER=TEMP.POLICYNUMBER
AND STATUS IN ('Fully Paid')
);
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(only adapted the dataset name), and got the same 5 records.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 07:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403820#M3703</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-13T07:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate values are removed without consent.</title>
      <link>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403829#M3704</link>
      <description>&lt;P&gt;But how come my results are removed?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 08:11:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/Duplicate-values-are-removed-without-consent/m-p/403829#M3704</guid>
      <dc:creator>Wken1122</dc:creator>
      <dc:date>2017-10-13T08:11:10Z</dc:date>
    </item>
  </channel>
</rss>

