<?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: How to convert SAS Code to SQL ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653387#M196267</link>
    <description>&lt;P&gt;T-SQL&lt;/P&gt;</description>
    <pubDate>Thu, 04 Jun 2020 17:44:25 GMT</pubDate>
    <dc:creator>prabha8934</dc:creator>
    <dc:date>2020-06-04T17:44:25Z</dc:date>
    <item>
      <title>How to convert SAS Code to SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653276#M196230</link>
      <description>&lt;P&gt;data covg_overlap_flag_2019;&lt;BR /&gt;set covg_rec_2019_sorted (keep=POIDS);&lt;BR /&gt;by POIDS;&lt;BR /&gt;merge covg_rec_2019_sorted&lt;BR /&gt;covg_rec_2019_sorted (firstobs=2 keep=BNFT_CVG_EFFECTIVE_DT BNFT_CVG_TERM_DT rename=(BNFT_CVG_EFFECTIVE_DT=next_sd)&lt;BR /&gt;rename=(BNFT_CVG_TERM_DT=next_ed));&lt;BR /&gt;if (first.POIDS=0 and BNFT_CVG_EFFECTIVE_DT&amp;lt;lag(BNFT_CVG_TERM_DT)) or&lt;BR /&gt;(BNFT_CVG_TERM_DT&amp;gt;next_sd and last.POIDS=0) then flag+1;&lt;BR /&gt;else&lt;BR /&gt;if (first.POIDS=0 and BNFT_CVG_EFFECTIVE_DT=lag(BNFT_CVG_EFFECTIVE_DT))&lt;BR /&gt;or (first.POIDS=0 and BNFT_CVG_TERM_DT=lag(BNFT_CVG_TERM_DT))&lt;BR /&gt;then flag+1;&lt;/P&gt;&lt;P&gt;else if (last.POIDS=0 and BNFT_CVG_EFFECTIVE_DT=next_sd) or&lt;BR /&gt;(BNFT_CVG_TERM_DT=next_ed and last.POIDS=0)&lt;BR /&gt;then flag+1;&lt;BR /&gt;else flag=0;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 15:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653276#M196230</guid>
      <dc:creator>prabha8934</dc:creator>
      <dc:date>2020-06-04T15:51:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert SAS Code to SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653280#M196234</link>
      <description>&lt;P&gt;Since SQL really doesn't have much of a concept of reading records by order anything that uses First. or Last. constructs in a data step is going to require a lot of not trivial SQL to get an equivalent. And that is a maybe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use of LAG and DIF functions is right out. You would need a separate ordered join to get each "lag" value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If that works why would want to replace it?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 16:07:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653280#M196234</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-04T16:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert SAS Code to SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653357#M196247</link>
      <description>&lt;P&gt;Some SQL languages support lag and (may be dif) but I haven't seen a construct where first. and last. exist. Things that come close to this behavior is using a windowing function and creating a non tied rank. Us teh rank so obtained in the processing&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 16:51:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653357#M196247</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-04T16:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert SAS Code to SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653383#M196265</link>
      <description>What flavour of SQL? PL/SQL or cursor logic may help but it's painful.</description>
      <pubDate>Thu, 04 Jun 2020 17:43:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653383#M196265</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-04T17:43:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert SAS Code to SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653384#M196266</link>
      <description>&lt;P&gt;Thank you. That's true SQL doesn't have many features like SAS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:43:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653384#M196266</guid>
      <dc:creator>prabha8934</dc:creator>
      <dc:date>2020-06-04T17:43:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert SAS Code to SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653387#M196267</link>
      <description>&lt;P&gt;T-SQL&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 17:44:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653387#M196267</guid>
      <dc:creator>prabha8934</dc:creator>
      <dc:date>2020-06-04T17:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert SAS Code to SQL ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653422#M196286</link>
      <description>&lt;P&gt;IMHO, don't use SQL for purposes it wasn't designed for. The code you've supplied isn't easily translatable into T-SQL. What is wrong with continuing to process in SAS and then load the results into the database?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2020 19:56:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-convert-SAS-Code-to-SQL/m-p/653422#M196286</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2020-06-04T19:56:20Z</dc:date>
    </item>
  </channel>
</rss>

