<?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: SAS Logic question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374301#M89617</link>
    <description>Right. Year info is available too. I just didnt include it here since it was an example.&lt;BR /&gt;&lt;BR /&gt;I am interested in checking a value of "Yes" for rex in last 3 days and if that happens..&lt;BR /&gt;&lt;BR /&gt;A value of ram &amp;lt;&amp;gt; r in the past 6 days.&lt;BR /&gt;&lt;BR /&gt;if these both conditions match.. the value for ram today will be r.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Sun, 09 Jul 2017 18:14:23 GMT</pubDate>
    <dc:creator>adityaa9z</dc:creator>
    <dc:date>2017-07-09T18:14:23Z</dc:date>
    <item>
      <title>SAS Logic question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374271#M89607</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Need a suggestion ,regarding one of the programming logics I need to figure out. There is a dataset named A and in A there is variable named rex, which has values Yes or No and a variable named ram which has a value of r or Null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) If in the last THREE&amp;nbsp;days, the value of rex is Yes, then we have to check the following conditions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;--Check whether the value of rex was "Yes" in the past SIX days AND value of ram was not equal to "r", - If this condition matches, then the value of ram should be populated as "r", else Null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) If not the value of ram stays as null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The jobs runs daily for each day, so the data will check the previous days to match the conditions and populate the values of ram based on it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if this makes some sense or if you have more questions around it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 15:14:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374271#M89607</guid>
      <dc:creator>adityaa9z</dc:creator>
      <dc:date>2017-07-09T15:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Logic question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374287#M89610</link>
      <description>&lt;P&gt;1) Is the date part of dataset name or is it a variable in the dataset?&lt;/P&gt;
&lt;P&gt;2) What is the name-format of the datasets? how do you distinguish between datasets of different days?&lt;/P&gt;
&lt;P&gt;3) please post at least on dataset example, better in a format like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
   input rex $ ram $;
cards;
a r
a 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;4) Does each daily dataset have one row only or more?&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;If more - which row should be checked ?&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 16:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374287#M89610</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-09T16:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Logic question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374290#M89611</link>
      <description>&lt;P&gt;In addition to the questions&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/88384"&gt;@Shmuel&lt;/a&gt;&amp;nbsp;asked, here are a couple more:&lt;/P&gt;
&lt;P&gt;1. are you just adding a new record for the current day or is that record already in the dataset&lt;/P&gt;
&lt;P&gt;2. is it just one record or is there also some kind of id field and this has to be done for all ids&lt;/P&gt;
&lt;P&gt;3. if the code has to add a record for today, how should the variable ram be populated (i.e., yes or no)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 17:01:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374290#M89611</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-09T17:01:54Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Logic question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374297#M89613</link>
      <description>&lt;P&gt;1) Date is not the part of dataset. I am calculating it from today -3 days and today - 6 days.&lt;/P&gt;&lt;P&gt;2) Its just a single dataset. Records get appended to it daily. So if today is 1/1/2017. Records for 12/31/2016 will get appended to A.&lt;/P&gt;&lt;P&gt;4) Its a single dataset, has a million records and records get appended to i daily..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, take for example&lt;BR /&gt;Below are the records which already exist in the DS&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;date rex ram&lt;BR /&gt;12/26 Yes .&lt;BR /&gt;12/27 Yes r &amp;nbsp; &amp;nbsp; /*(Has rex as yes in past 3 days and ram &amp;lt;&amp;gt; null in last 6 days, so ram is populated as&amp;nbsp;r)*/&lt;/P&gt;&lt;P&gt;12/28 No .&lt;BR /&gt;12/29 Yes r &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;SPAN&gt;/*(Has rex as yes in past 3(12/27) days and ram &amp;lt;&amp;gt; null(12/26) in last 6 days, so ram is populated as&amp;nbsp;r)*/&lt;/SPAN&gt;&lt;BR /&gt;12/30 No &amp;nbsp;.&lt;BR /&gt;12/31 No&amp;nbsp;.&lt;BR /&gt;1/1 No .&lt;BR /&gt;1/2 Yes . &amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;/*(rex is no in past 3 days so ram is null)*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Let me know if this helps. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 17:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374297#M89613</guid>
      <dc:creator>adityaa9z</dc:creator>
      <dc:date>2017-07-09T17:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Logic question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374299#M89615</link>
      <description>&lt;P&gt;Am I right:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have a dataset with 3 variables: date, rex, ram.&lt;/P&gt;
&lt;P&gt;The dataset contains one observation per day, accumulating more than one year.&lt;/P&gt;
&lt;P&gt;The date is in a format of mm/dd without a year info.&lt;/P&gt;
&lt;P&gt;Daily data is appended to the end of the dataset.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you are intertested in the last 6 observations only, in order to check according to rules and assign a value to ram variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need stop now and continue later.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jul 2017 18:04:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374299#M89615</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-09T18:04:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Logic question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374301#M89617</link>
      <description>Right. Year info is available too. I just didnt include it here since it was an example.&lt;BR /&gt;&lt;BR /&gt;I am interested in checking a value of "Yes" for rex in last 3 days and if that happens..&lt;BR /&gt;&lt;BR /&gt;A value of ram &amp;lt;&amp;gt; r in the past 6 days.&lt;BR /&gt;&lt;BR /&gt;if these both conditions match.. the value for ram today will be r.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Sun, 09 Jul 2017 18:14:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374301#M89617</guid>
      <dc:creator>adityaa9z</dc:creator>
      <dc:date>2017-07-09T18:14:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Logic question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374311#M89620</link>
      <description>&lt;P&gt;Assuming you have or can calculate the observation date:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set have;
        td = today();
        d_3 = td - 3;
        d_6 = td - 6;
        call symput('firstobs', left(obs - 10));
        call symput('d_3', left(d_3));
        call symput('d_6', left(d_6));
run;

data want;
  set have end = eof;
        retain stat_rex stat_ram 0;
        if date  &amp;gt; &amp;amp;d_3 and
           rex = 'YES'    then stat_rex = 1;
        if  date &amp;gt; &amp;amp;d_6 and ram ne  'r' then  stat_ram = 1;

       if eof and stat_rex=1 and stat_ram = 1 then ram = 'r' ;
       else ram = ' ';     /* last obs is todays obs, last appended */&lt;BR /&gt;       drop stat_rex stat_ram;
run;&lt;BR /&gt;&lt;BR /&gt;/*** I cannot test it so check it carefully ***/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 09 Jul 2017 19:28:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374311#M89620</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2017-07-09T19:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Logic question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374392#M89635</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/129089"&gt;@adityaa9z&lt;/a&gt; That's when before / after examples save time and confusion.</description>
      <pubDate>Mon, 10 Jul 2017 07:44:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Logic-question/m-p/374392#M89635</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2017-07-10T07:44:23Z</dc:date>
    </item>
  </channel>
</rss>

