<?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 Applying the correct rate. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Applying-the-correct-rate/m-p/787489#M251633</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to create a dataset with the following rules.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Pull in the correct rate for each&amp;nbsp;pdt_serv_id_num from the RATE_TBL to the CLAIMS_TBL.&lt;/P&gt;&lt;P&gt;2)For every pdt_serv_id_num, If the end_date is &lt;STRONG&gt;other than&lt;/STRONG&gt; 29991231, then the rate should be 0 until a record with the end_date 29991231 is found.&lt;/P&gt;&lt;P&gt;3) if a&amp;nbsp;pdt_serv_id_num in the&amp;nbsp;CLAIMS_TBL is not in the RATE_TBL then set the rate to 0.&lt;/P&gt;&lt;P&gt;4) the final dataset should have the same number of records in the&amp;nbsp;CLAIMS_TBL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have posted the two datasets and what the outcome should be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA RATE_TBL;&lt;/P&gt;&lt;P&gt;INPUT pdt_serv_id_num $11. effective_date Rate1 Rate2 End_Dt; DATALINES;&lt;/P&gt;&lt;P&gt;50242021060 20210901 0.1575 0.1635 29991231&lt;/P&gt;&lt;P&gt;50242021060 20210801 0.15 0.15 29991231&lt;/P&gt;&lt;P&gt;00002144509 20210801 0.18 0.19 29991231&lt;/P&gt;&lt;P&gt;00002144509 20211001 0.18 0.19 20210930&lt;/P&gt;&lt;P&gt;00002144509 20220101 0.1732 0.2467 29991231 ; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA CLAIMS_TBL;&lt;/P&gt;&lt;P&gt;INPUT PCH_DATE&amp;nbsp; pdt_serv_id_num $11.;&lt;/P&gt;&lt;P&gt;DATALINES;&lt;/P&gt;&lt;P&gt;20211005 50242021060&lt;/P&gt;&lt;P&gt;20210812 50242021060&lt;/P&gt;&lt;P&gt;20210829 50242021060&lt;/P&gt;&lt;P&gt;20211010 50242021060&lt;/P&gt;&lt;P&gt;20211108 50242021060&lt;/P&gt;&lt;P&gt;20210913 50242021060&lt;/P&gt;&lt;P&gt;20211026 50242021060&lt;/P&gt;&lt;P&gt;20210928 50242021060&lt;/P&gt;&lt;P&gt;20211109 78206013801&lt;/P&gt;&lt;P&gt;20211028 78206013801&lt;/P&gt;&lt;P&gt;20210831 00002144509&lt;/P&gt;&lt;P&gt;20210901 00002144509&lt;/P&gt;&lt;P&gt;20210929 00002144509&lt;/P&gt;&lt;P&gt;20211004 00002144509&lt;/P&gt;&lt;P&gt;20211112 00002144509&lt;/P&gt;&lt;P&gt;20220112 00002144509&lt;/P&gt;&lt;P&gt;20220226 00002144509&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;/P&gt;&lt;P&gt;INPUT PCH_DATE pdt_serv_id_num $11. Rate1 Rate2; DATALINES;&lt;/P&gt;&lt;P&gt;20210831 00002144509 0.18 0.19&lt;/P&gt;&lt;P&gt;20210901 00002144509 0.18 0.19&lt;/P&gt;&lt;P&gt;20211029 00002144509 0 0&lt;/P&gt;&lt;P&gt;20211004 00002144509 0 0&lt;/P&gt;&lt;P&gt;20211112 00002144509 0 0&lt;/P&gt;&lt;P&gt;20220112 00002144509 0.1732 0.2467&lt;/P&gt;&lt;P&gt;20220226 00002144509 0.1732 0.2467&lt;/P&gt;&lt;P&gt;20211005 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20210812 50242021060 0.15 0.15&lt;/P&gt;&lt;P&gt;20210829 50242021060 0.15 0.15&lt;/P&gt;&lt;P&gt;20211010 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20211108 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20210913 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20211026 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20210928 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20211109 78206013801 0 0&lt;/P&gt;&lt;P&gt;20211028 78206013801 0 0&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope what I am looking for helps. If not, please let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Dec 2021 21:44:06 GMT</pubDate>
    <dc:creator>tgbcbsm</dc:creator>
    <dc:date>2021-12-27T21:44:06Z</dc:date>
    <item>
      <title>Applying the correct rate.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-the-correct-rate/m-p/787489#M251633</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to create a dataset with the following rules.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) Pull in the correct rate for each&amp;nbsp;pdt_serv_id_num from the RATE_TBL to the CLAIMS_TBL.&lt;/P&gt;&lt;P&gt;2)For every pdt_serv_id_num, If the end_date is &lt;STRONG&gt;other than&lt;/STRONG&gt; 29991231, then the rate should be 0 until a record with the end_date 29991231 is found.&lt;/P&gt;&lt;P&gt;3) if a&amp;nbsp;pdt_serv_id_num in the&amp;nbsp;CLAIMS_TBL is not in the RATE_TBL then set the rate to 0.&lt;/P&gt;&lt;P&gt;4) the final dataset should have the same number of records in the&amp;nbsp;CLAIMS_TBL&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have posted the two datasets and what the outcome should be.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA RATE_TBL;&lt;/P&gt;&lt;P&gt;INPUT pdt_serv_id_num $11. effective_date Rate1 Rate2 End_Dt; DATALINES;&lt;/P&gt;&lt;P&gt;50242021060 20210901 0.1575 0.1635 29991231&lt;/P&gt;&lt;P&gt;50242021060 20210801 0.15 0.15 29991231&lt;/P&gt;&lt;P&gt;00002144509 20210801 0.18 0.19 29991231&lt;/P&gt;&lt;P&gt;00002144509 20211001 0.18 0.19 20210930&lt;/P&gt;&lt;P&gt;00002144509 20220101 0.1732 0.2467 29991231 ; RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA CLAIMS_TBL;&lt;/P&gt;&lt;P&gt;INPUT PCH_DATE&amp;nbsp; pdt_serv_id_num $11.;&lt;/P&gt;&lt;P&gt;DATALINES;&lt;/P&gt;&lt;P&gt;20211005 50242021060&lt;/P&gt;&lt;P&gt;20210812 50242021060&lt;/P&gt;&lt;P&gt;20210829 50242021060&lt;/P&gt;&lt;P&gt;20211010 50242021060&lt;/P&gt;&lt;P&gt;20211108 50242021060&lt;/P&gt;&lt;P&gt;20210913 50242021060&lt;/P&gt;&lt;P&gt;20211026 50242021060&lt;/P&gt;&lt;P&gt;20210928 50242021060&lt;/P&gt;&lt;P&gt;20211109 78206013801&lt;/P&gt;&lt;P&gt;20211028 78206013801&lt;/P&gt;&lt;P&gt;20210831 00002144509&lt;/P&gt;&lt;P&gt;20210901 00002144509&lt;/P&gt;&lt;P&gt;20210929 00002144509&lt;/P&gt;&lt;P&gt;20211004 00002144509&lt;/P&gt;&lt;P&gt;20211112 00002144509&lt;/P&gt;&lt;P&gt;20220112 00002144509&lt;/P&gt;&lt;P&gt;20220226 00002144509&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA WANT;&lt;/P&gt;&lt;P&gt;INPUT PCH_DATE pdt_serv_id_num $11. Rate1 Rate2; DATALINES;&lt;/P&gt;&lt;P&gt;20210831 00002144509 0.18 0.19&lt;/P&gt;&lt;P&gt;20210901 00002144509 0.18 0.19&lt;/P&gt;&lt;P&gt;20211029 00002144509 0 0&lt;/P&gt;&lt;P&gt;20211004 00002144509 0 0&lt;/P&gt;&lt;P&gt;20211112 00002144509 0 0&lt;/P&gt;&lt;P&gt;20220112 00002144509 0.1732 0.2467&lt;/P&gt;&lt;P&gt;20220226 00002144509 0.1732 0.2467&lt;/P&gt;&lt;P&gt;20211005 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20210812 50242021060 0.15 0.15&lt;/P&gt;&lt;P&gt;20210829 50242021060 0.15 0.15&lt;/P&gt;&lt;P&gt;20211010 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20211108 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20210913 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20211026 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20210928 50242021060 0.1575 0.1635&lt;/P&gt;&lt;P&gt;20211109 78206013801 0 0&lt;/P&gt;&lt;P&gt;20211028 78206013801 0 0&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope what I am looking for helps. If not, please let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Dec 2021 21:44:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-the-correct-rate/m-p/787489#M251633</guid>
      <dc:creator>tgbcbsm</dc:creator>
      <dc:date>2021-12-27T21:44:06Z</dc:date>
    </item>
    <item>
      <title>Re: Applying the correct rate.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Applying-the-correct-rate/m-p/788720#M252249</link>
      <description>&lt;P&gt;It seems like you are missing a rule:&amp;nbsp; what do you want when there are entries for &lt;SPAN&gt;pdt_serv_id_num&amp;nbsp;&lt;/SPAN&gt;in the RATE_TBL with overlapping dates?&amp;nbsp; For example, for&amp;nbsp;&lt;SPAN&gt;50242021060&amp;nbsp;there are entries with effective_date of&amp;nbsp;20210801&amp;nbsp;and&amp;nbsp;20210901, both with end_dt of&amp;nbsp;29991231.&amp;nbsp; So the entry in CLAIMS_TBL for&amp;nbsp;50242021060 with PCH_DATE of&amp;nbsp;20211108&amp;nbsp;matches both entries in the RATE_TBL.&amp;nbsp; Which should be used?&amp;nbsp; From your WANT table, it appears the rule is to use the record in the RATE_TBL with&amp;nbsp;end_dt of&amp;nbsp;29991231 that has the maximum effective date that is less than PCH_DATE, so in this case it is the&amp;nbsp;RATE_TBL entry with&amp;nbsp;effective_date of&amp;nbsp;20210901.&amp;nbsp; Is this correct?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 18:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Applying-the-correct-rate/m-p/788720#M252249</guid>
      <dc:creator>GarthHelf</dc:creator>
      <dc:date>2022-01-06T18:40:18Z</dc:date>
    </item>
  </channel>
</rss>

