<?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 Explanation if statement in arithmetic calculation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Explanation-if-statement-in-arithmetic-calculation/m-p/103248#M291236</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please tell me where the following piece of code says not to add 88 if month&amp;lt;&amp;gt;12. I thought it says add 88*multiplied by(dec of each year)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro cohort1(mth);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /**DETERMINING FIRST AND LAST MONTH OF PERFORMANCE**/&lt;/P&gt;&lt;P&gt;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("start_mon", &amp;amp;mth+1 + 88*(substr("&amp;amp;mth.",5,2) = 12));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("end_mon", &amp;amp;mth+100 );&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put &amp;amp;start_mon &amp;amp;end_mon;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%cohort1(200512);&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Explanation if statement in arithmetic calculation&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 07 Aug 2013 09:10:01 GMT</pubDate>
    <dc:creator>M_ishk_a</dc:creator>
    <dc:date>2013-08-07T09:10:01Z</dc:date>
    <item>
      <title>Explanation if statement in arithmetic calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Explanation-if-statement-in-arithmetic-calculation/m-p/103248#M291236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please tell me where the following piece of code says not to add 88 if month&amp;lt;&amp;gt;12. I thought it says add 88*multiplied by(dec of each year)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%macro cohort1(mth);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; /**DETERMINING FIRST AND LAST MONTH OF PERFORMANCE**/&lt;/P&gt;&lt;P&gt;&amp;nbsp; data _null_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("start_mon", &amp;amp;mth+1 + 88*(substr("&amp;amp;mth.",5,2) = 12));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput ("end_mon", &amp;amp;mth+100 );&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; %put &amp;amp;start_mon &amp;amp;end_mon;&lt;/P&gt;&lt;P&gt;%mend;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%cohort1(200512);&lt;SPAN style="font-size: 11.0pt; font-family: 'Calibri','sans-serif';"&gt;Explanation if statement in arithmetic calculation&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 09:10:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Explanation-if-statement-in-arithmetic-calculation/m-p/103248#M291236</guid>
      <dc:creator>M_ishk_a</dc:creator>
      <dc:date>2013-08-07T09:10:01Z</dc:date>
    </item>
    <item>
      <title>Re: Explanation if statement in arithmetic calculation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Explanation-if-statement-in-arithmetic-calculation/m-p/103249#M291237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Explanation is as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;The line of code &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;call symput ("start_mon", &amp;amp;mth+1 + 88*(substr("&amp;amp;mth.",5,2) = "12"));&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;is saying the following&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;if (substr("&amp;amp;mth.",5,2) = "12") then call symput ("another_start_mon", &amp;amp;mth + 1 + 88);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;else call symput ("another_start_mon", &amp;amp;mth+1);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;how the shorten line of codes works as follows:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SAS evaluates quantities inside parentheses before performing any operations.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Let’s call the macro with the following value %cohort1(200512).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;SAS will first evaluate the parentheses (substr("&amp;amp;mth.",5,2) = "12")) in this case &amp;amp;mth is 12 so the value inside the parameter would be true or 1.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;So the expression is actually &amp;amp;mth+1 + 88*(1).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;amp;mth will the evaluate &amp;amp;mth plus 1 plus (88 * 1)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Let’s call the macro with the following value %cohort1(200601) in this case &amp;amp;mth is not 12 so the value inside the parameter would be false or 0.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;So the expression is actually &amp;amp;mth+1 + 88*(0).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;amp;mth will the evaluate &amp;amp;mth plus 1 plus (88 * 0)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;SPAN&gt;Fruther reading: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm#a000781136"&gt;http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a000780367.htm#a000781136&lt;/A&gt;&lt;SPAN&gt; see Numeric Comparisons&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 07 Aug 2013 09:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Explanation-if-statement-in-arithmetic-calculation/m-p/103249#M291237</guid>
      <dc:creator>arnouxvr</dc:creator>
      <dc:date>2013-08-07T09:18:24Z</dc:date>
    </item>
  </channel>
</rss>

