<?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: SAS, array code, two indices, dropping records in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/SAS-array-code-two-indices-dropping-records/m-p/504895#M1049</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/225082"&gt;@user112a2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am looking through some code and wondering what this does. Below are the code comments. I'm still not sure what this code does even with the code comments. I have used arrays but not familiar with this code. It looks like this code dedupes by using two indices. Is that correct? So if there is a combination of CCS_DR_IDX and TXN_IDX, it will delete those records?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now handle cases where the dollar matches. If ccs_dr_idx has already been used then delete the record. Dropped txns here will be added back in with the claim data called missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA=OUT.REQ_1_9_F_AMT_MATCH; BY CCS_DR_IDX DATEDIF; RUN;

    DATA OUT.REQ_1_9_F_AMT_MATCH_V2;
        SET OUT.REQ_1_9_F_AMT_MATCH;

        ARRAY id_one{40000} id_one1-id_one40000;
        ARRAY id_two{40000} id_two1-id_two40000;

        RETAIN id_one1-id_one40000 id_two1-id_two40000;

        IF _n_=1 then i=1;
        else i+1;

        do j=1 to i;
            if CCS_DR_IDX=id_one{j} then delete;
        end;

        do k = 1 to i;
                if TXN_IDX = id_two{k} then delete;
        end;

        id_one{i}=CCS_DR_IDX;
        id_two{i}=TXN_IDX;

        drop i j k  id_one1-id_one40000 id_two1-id_two40000;

    run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you have data? If so, did you run the code against that data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 16 Oct 2018 21:07:26 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-10-16T21:07:26Z</dc:date>
    <item>
      <title>SAS, array code, two indices, dropping records</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-array-code-two-indices-dropping-records/m-p/504887#M1046</link>
      <description>&lt;P&gt;I am looking through some code and wondering what this does. Below are the code comments. I'm still not sure what this code does even with the code comments. I have used arrays but not familiar with this code. It looks like this code dedupes by using two indices. Is that correct? So if there is a combination of CCS_DR_IDX and TXN_IDX, it will delete those records?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now handle cases where the dollar matches. If ccs_dr_idx has already been used then delete the record. Dropped txns here will be added back in with the claim data called missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Removed&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Apr 2019 17:43:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-array-code-two-indices-dropping-records/m-p/504887#M1046</guid>
      <dc:creator>user112a2</dc:creator>
      <dc:date>2019-04-26T17:43:33Z</dc:date>
    </item>
    <item>
      <title>Re: SAS, array code, two indices, dropping records</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-array-code-two-indices-dropping-records/m-p/504895#M1049</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/225082"&gt;@user112a2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I am looking through some code and wondering what this does. Below are the code comments. I'm still not sure what this code does even with the code comments. I have used arrays but not familiar with this code. It looks like this code dedupes by using two indices. Is that correct? So if there is a combination of CCS_DR_IDX and TXN_IDX, it will delete those records?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now handle cases where the dollar matches. If ccs_dr_idx has already been used then delete the record. Dropped txns here will be added back in with the claim data called missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SORT DATA=OUT.REQ_1_9_F_AMT_MATCH; BY CCS_DR_IDX DATEDIF; RUN;

    DATA OUT.REQ_1_9_F_AMT_MATCH_V2;
        SET OUT.REQ_1_9_F_AMT_MATCH;

        ARRAY id_one{40000} id_one1-id_one40000;
        ARRAY id_two{40000} id_two1-id_two40000;

        RETAIN id_one1-id_one40000 id_two1-id_two40000;

        IF _n_=1 then i=1;
        else i+1;

        do j=1 to i;
            if CCS_DR_IDX=id_one{j} then delete;
        end;

        do k = 1 to i;
                if TXN_IDX = id_two{k} then delete;
        end;

        id_one{i}=CCS_DR_IDX;
        id_two{i}=TXN_IDX;

        drop i j k  id_one1-id_one40000 id_two1-id_two40000;

    run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Do you have data? If so, did you run the code against that data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 21:07:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-array-code-two-indices-dropping-records/m-p/504895#M1049</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-16T21:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS, array code, two indices, dropping records</title>
      <link>https://communities.sas.com/t5/New-SAS-User/SAS-array-code-two-indices-dropping-records/m-p/504909#M1053</link>
      <description>&lt;P&gt;It looks like it is an attempt to eliminate records where either of two variables' value is already included in the output data.&lt;/P&gt;
&lt;P&gt;Notice how it waits to save the values until after the possible DELETE statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The SORT will impact which of the possible duplicates is kept since the first a value is seen the observations is kept (output) and later ones are deleted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could simplify the data step code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA OUT.REQ_1_9_F_AMT_MATCH_V2;
   SET OUT.REQ_1_9_F_AMT_MATCH;

   ARRAY id_one{40000} _temporary_;
   ARRAY id_two{40000} _temporary_;

   if CCS_DR_IDX in id_one then delete;
   if TXN_IDX in id_two then delete;

   id_one{_n_}=CCS_DR_IDX;
   id_two{_n_}=TXN_IDX;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If there are a lot of re-used codes then you could&amp;nbsp; reduce the size of the arrays by keeping your own counter as the index to the array. That way the arrays just need to be large enough to match the size of the output dataset, and not the size of the input dataset.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA OUT.REQ_1_9_F_AMT_MATCH_V2;
   SET OUT.REQ_1_9_F_AMT_MATCH;

   ARRAY id_one{40000} _temporary_;
   ARRAY id_two{40000} _temporary_;

   if CCS_DR_IDX in id_one then delete;
   if TXN_IDX in id_two then delete;

   i+1;
   id_one{i}=CCS_DR_IDX;
   id_two{i}=TXN_IDX;
   drop i;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you could also just use hashes instead of arrays and possible increase the speed and the size of datasets it could handle.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Oct 2018 21:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/SAS-array-code-two-indices-dropping-records/m-p/504909#M1053</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2018-10-16T21:43:04Z</dc:date>
    </item>
  </channel>
</rss>

