<?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: Need help to convert sas code to sql in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843459#M36596</link>
    <description>&lt;P&gt;yes that's acceptable.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Nov 2022 20:10:06 GMT</pubDate>
    <dc:creator>Venu1981</dc:creator>
    <dc:date>2022-11-09T20:10:06Z</dc:date>
    <item>
      <title>Need help to convert sas code to sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843457#M36594</link>
      <description>&lt;P&gt;Here's what I see in SAS. Can someone help me with equivalent sql code of it please!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Indicator of how runout is handled cs_runout: 1 = extend from plan year end date,&lt;BR /&gt;2 = extend from termination, 3 = extend from date of claim, 4 = no runout 5 = Extend from grace period end;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;IF cs_runout = 1 THEN DO;
  IF days = 15 THEN DO;
    IF ms_end=INTNX("MONTH",ms_end,0,"END") THEN runout=INTNX('MONTH',ms_end,runout_period,'END')+15;
%*If ms_end is last day of month then move to last day of future month then add 15;
    ELSE runout=INTNX('MONTH',ms_end,runout_period,'SAMEDAY')+15;
%*If ms_end is NOT last day of month then move to SAMEDAY of future month then add 15;
    put "Values in runout: " mb_subid= ms_end= runout_period= days= runout=;
  END;
  ELSE DO;
    IF ms_end=INTNX("MONTH",ms_end,0,"END") THEN runout=INTNX('MONTH',ms_end,runout_period,'END');
%*If ms_end is last day of month then move to last day of future month;
    ELSE runout=INTNX('MONTH',ms_end,runout_period,'SAMEDAY');
%*If ms_end is NOT last day of month then move to SAMEDAY of future month;
    put "Values in runout: " mb_subid= ms_end= runout_period= days= runout=;
  END;
*** ???? ***;
END;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Editted: ** I tried to convert what you posted into something that looks like SAS code.&amp;nbsp; **&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 20:07:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843457#M36594</guid>
      <dc:creator>Venu1981</dc:creator>
      <dc:date>2022-11-09T20:07:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to convert sas code to sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843458#M36595</link>
      <description>SAS SQL or a different flavour of SQL?&lt;BR /&gt;It's basically CASE statements and you will lose the PUT functionality. Is that acceptable?</description>
      <pubDate>Wed, 09 Nov 2022 20:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843458#M36595</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-09T20:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to convert sas code to sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843459#M36596</link>
      <description>&lt;P&gt;yes that's acceptable.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 20:10:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843459#M36596</guid>
      <dc:creator>Venu1981</dc:creator>
      <dc:date>2022-11-09T20:10:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to convert sas code to sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843460#M36597</link>
      <description>Hi Reeza, yes, that's acceptable.</description>
      <pubDate>Wed, 09 Nov 2022 20:10:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843460#M36597</guid>
      <dc:creator>Venu1981</dc:creator>
      <dc:date>2022-11-09T20:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to convert sas code to sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843462#M36598</link>
      <description>And SQL type? SAS SQL? That will affect if the INTNX function can be used. &lt;BR /&gt;Also, do you still need help, you've marked this solved.&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Nov 2022 20:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843462#M36598</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-09T20:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to convert sas code to sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843464#M36599</link>
      <description>Hi, any sql will do. It's not resolved, not sure who updated the status&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Nov 2022 20:27:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843464#M36599</guid>
      <dc:creator>Venu1981</dc:creator>
      <dc:date>2022-11-09T20:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to convert sas code to sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843468#M36600</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/436956"&gt;@Venu1981&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi, any sql will do. It's not resolved, not sure who updated the status&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You did.&amp;nbsp; You can unselect it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you know SQL or not?&lt;/P&gt;
&lt;P&gt;The syntax for CASE is different.&amp;nbsp; The result of the CASE clause is a value which you can then include as a variable in the list of variables in your select clause.&lt;/P&gt;
&lt;P&gt;So your snippet is essentially this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when (cs_runout = 1) THEN 
  case when (days = 15) THEN 
    case when (ms_end=INTNX("MONTH",ms_end,0,"END")) THEN INTNX('MONTH',ms_end,runout_period,'END')+15
         else . 
    end
    else INTNX('MONTH',ms_end,runout_period,'SAMEDAY')+15
  else
    case when (ms_end=INTNX("MONTH",ms_end,0,"END")) THEN INTNX('MONTH',ms_end,runout_period,'END')
         else INTNX('MONTH',ms_end,runout_period,'SAMEDAY')
    end
  end
else .
end as runout
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But to do a full translation you need to provide a full program.&lt;/P&gt;
&lt;P&gt;For example instead of returning empty values for the ELSE steps in your data step code that did nothing to the RUNOUT variable perhaps you want to select the existing value of the RUNOUT variable (or some other variable) instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 20:40:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843468#M36600</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-09T20:40:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need help to convert sas code to sql</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843470#M36601</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;case when (cs_runout=1 &amp;amp; days=15 &amp;amp; ms_end=INTNX("MONTH", ms_end, 0, "END")) then INTNX('MONTH', ms_end, runout_period, 'END')+15 
	when (cs_runout=1 &amp;amp; days=15 &amp;amp; ms_end ne INTNX("MONTH", ms_end, 0, "END")) then INTNX('MONTH', ms_end, runout_period, 'SAMEDAY')+15 
	when (cs_runout=1 &amp;amp; ms_end=INTNX("MONTH", ms_end, 0, "END")) then INTNX('MONTH', ms_end, runout_period, 'END') 
	when (cs_runout=1) then INTNX('MONTH', ms_end, runout_period, 'SAMEDAY') 
	else .
end as runout&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 09 Nov 2022 20:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Need-help-to-convert-sas-code-to-sql/m-p/843470#M36601</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-09T20:40:53Z</dc:date>
    </item>
  </channel>
</rss>

