<?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: Can someone explain this piece of code in plain language? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327471#M271667</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/118497"&gt;@confused_saser&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I should have looked it up but I actualyl dind't realize it was a function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Super new to SAS! thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought your confusion was with the expression 1 &amp;lt; value &amp;lt; 7, it was for me.&amp;nbsp; I had to write an example to make sure I knew what it was doing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data acc;
   do date_accident = today() to today()+10;
      weekday = weekday(date_accident);
      x = 1 &amp;lt; weekday(date_accident)&amp;lt; 7;
      y = 1 &amp;lt; weekday(date_accident) and weekday(date_accident) &amp;lt; 7;
      z = weekday(date_accident) not in (1 7);
      if (1 &amp;lt; weekday(date_accident)&amp;lt; 7) then calc_date_accident = date_accident-1; 
      else calc_date_accident = date_accident;
      output;
      end;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG title="Capture.PNG" alt="Capture.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/6884i73A71713C4C22A16/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jan 2017 18:07:16 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2017-01-25T18:07:16Z</dc:date>
    <item>
      <title>Can someone explain this piece of code in plain language?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327458#M271662</link>
      <description>&lt;P&gt;I don't think I understand exactly how this piece of code works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; if (1 &amp;lt; weekday(date_accident)&amp;lt; 7) then 
       calc_date_accident = date_accident-1; 
    else 
       calc_date_accident = date_accident;&lt;/PRE&gt;&lt;P&gt;I understand what it is doing-I know that it is subtracting one day from the date_accident variable, but I don't think I understand what is happening in the "IF" statement, specifically the 1 and 7.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please explain what this code is actually saying?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 17:37:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327458#M271662</guid>
      <dc:creator>confused_saser</dc:creator>
      <dc:date>2017-01-25T17:37:30Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this piece of code in plain language?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327461#M271663</link>
      <description>&lt;P&gt;The expression is a shorthand for&lt;/P&gt;
&lt;PRE&gt;1 &amp;lt; weekday(date_accident) and weekday(date_accident) &amp;lt; 7&lt;/PRE&gt;
&lt;P&gt;you could also say&lt;/P&gt;
&lt;PRE&gt;IF weekday(date_accident) NOT IN (1 7);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not Saturday or Sunday. &amp;nbsp;See &lt;A href="http://support.sas.com/documentation/cdl/en/lefunctionsref/69762/HTML/default/viewer.htm#p0ahi8tk3trkv5n173sil9hd7c62.htm" target="_self"&gt;the WEEKDAY() function documentation&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 18:02:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327461#M271663</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-01-25T18:02:48Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this piece of code in plain language?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327462#M271664</link>
      <description>&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the 1 and the 7 actually represents Saturday and Sunday?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that mean I can select any day of the week by using these numbers in conjuction with "weekday". So &amp;nbsp;for example if I wanted to select Wednesday I would choose the number 4?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 17:52:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327462#M271664</guid>
      <dc:creator>confused_saser</dc:creator>
      <dc:date>2017-01-25T17:52:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this piece of code in plain language?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327465#M271665</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/118497"&gt;@confused_saser&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15410"&gt;@data_null__&lt;/a&gt;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the 1 and the 7 actually represents Saturday and Sunday?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that mean I can select any day of the week by using these numbers in conjuction with "weekday". So &amp;nbsp;for example if I wanted to select Wednesday I would choose the number 4?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sorry, I assumed&amp;nbsp;you had looked at the documention for the WEEKDAY function and knew what it was returning.&amp;nbsp; Yes today, Wednesday, is weekday 4.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 17:56:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327465#M271665</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-01-25T17:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this piece of code in plain language?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327466#M271666</link>
      <description>&lt;P&gt;I should have looked it up but I actualyl dind't realize it was a function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Super new to SAS! thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 17:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327466#M271666</guid>
      <dc:creator>confused_saser</dc:creator>
      <dc:date>2017-01-25T17:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this piece of code in plain language?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327471#M271667</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/118497"&gt;@confused_saser&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I should have looked it up but I actualyl dind't realize it was a function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Super new to SAS! thank you &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I thought your confusion was with the expression 1 &amp;lt; value &amp;lt; 7, it was for me.&amp;nbsp; I had to write an example to make sure I knew what it was doing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data acc;
   do date_accident = today() to today()+10;
      weekday = weekday(date_accident);
      x = 1 &amp;lt; weekday(date_accident)&amp;lt; 7;
      y = 1 &amp;lt; weekday(date_accident) and weekday(date_accident) &amp;lt; 7;
      z = weekday(date_accident) not in (1 7);
      if (1 &amp;lt; weekday(date_accident)&amp;lt; 7) then calc_date_accident = date_accident-1; 
      else calc_date_accident = date_accident;
      output;
      end;
   run;
proc print;
   run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;IMG title="Capture.PNG" alt="Capture.PNG" src="https://communities.sas.com/t5/image/serverpage/image-id/6884i73A71713C4C22A16/image-size/original?v=1.0&amp;amp;px=-1" border="0" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 18:07:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327471#M271667</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2017-01-25T18:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can someone explain this piece of code in plain language?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327563#M271668</link>
      <description>Thought you might (at cost of a little complexity) have reduced the code to &lt;BR /&gt;&lt;BR /&gt;Calc_date_accident  = date_accident - not ( weekday( date_accident ) in( 1, 7 ) ) ;&lt;BR /&gt;&lt;BR /&gt;Since the results of SAS logical operations are either 0 or 1, the composite above achieves what appears to be wanted....&lt;BR /&gt;   &lt;BR /&gt;I'm just interested in what activity requires this adjustment for Monday to Friday but not for Saturday and Sunday....?&lt;BR /&gt;</description>
      <pubDate>Wed, 25 Jan 2017 22:22:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Can-someone-explain-this-piece-of-code-in-plain-language/m-p/327563#M271668</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2017-01-25T22:22:22Z</dc:date>
    </item>
  </channel>
</rss>

