<?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 find the  usage  within two dates in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710443#M37962</link>
    <description>Thanks for your answer! Not sure if I can use proc sql as I was asked to use proc freq instead. I tried the code and it gives me an error syntax at the where clause.</description>
    <pubDate>Sun, 10 Jan 2021 13:54:48 GMT</pubDate>
    <dc:creator>Hiandbye</dc:creator>
    <dc:date>2021-01-10T13:54:48Z</dc:date>
    <item>
      <title>How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710435#M37958</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;Can you please help me find how to filter a data set that contains two variables: Model _ID and Date_Received. What I need is to find the number of runs of the models within last 7 days, 30days ,1 year.&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;So if we ran it today, it would count usage between 03Jan2020 - 10Jan2020 inclusive ,&lt;DIV&gt;if we run it tomorrow, it would count usage between 04Jan2020 - 11Jan2020 inclusive etc. The output data should be a table that has the models and the number of runs only.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I have chosen to do a proc freq step but don't know how filter the dates, any help is much appreciated!&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 10 Jan 2021 20:17:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710435#M37958</guid>
      <dc:creator>Hiandbye</dc:creator>
      <dc:date>2021-01-10T20:17:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710438#M37959</link>
      <description>&lt;P&gt;To select models received in a period use where clause:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where &amp;lt;date&amp;gt; between &amp;lt;date1&amp;gt; and &amp;lt;date2&amp;gt;; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or more specifically as in your case:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where last_run between today()-6 and today();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You can use it in a data step to extract the data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data part;
 set have(where=(last_run in ...));
   ...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;or in a procedure - proc freq to count how many models run on each day:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc frec data=have(where=(last_run between ...));;
   table lasr_run;
   format last_run &amp;lt;any date format ended with a dot&amp;gt;;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Jan 2021 13:27:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710438#M37959</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-10T13:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710440#M37960</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
  select
    model_id,
    count(*) as count
  from have
  group by model_id
  where today() - 7 le date_received le today()
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Untested; for tested code, supply your dataset in a data step with datalines, and post the code in a window opened with the "little running man" button (8th in the photo).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot_20210110-134550_Chrome.jpg" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/53370iEB19A1F1F3E487C6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_20210110-134550_Chrome.jpg" alt="Screenshot_20210110-134550_Chrome.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 13:32:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710440#M37960</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-10T13:32:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710442#M37961</link>
      <description>&lt;P&gt;Thank you for your answer but I get a syntax error when I tried it.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=MORIS.Test_notification_data  ;
tables Model_ID /nopercent ;
where  dt_rec between today()-6 and today();
RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 10 Jan 2021 20:07:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710442#M37961</guid>
      <dc:creator>Hiandbye</dc:creator>
      <dc:date>2021-01-10T20:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710443#M37962</link>
      <description>Thanks for your answer! Not sure if I can use proc sql as I was asked to use proc freq instead. I tried the code and it gives me an error syntax at the where clause.</description>
      <pubDate>Sun, 10 Jan 2021 13:54:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710443#M37962</guid>
      <dc:creator>Hiandbye</dc:creator>
      <dc:date>2021-01-10T13:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710444#M37963</link>
      <description />
      <pubDate>Sun, 10 Jan 2021 20:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710444#M37963</guid>
      <dc:creator>Hiandbye</dc:creator>
      <dc:date>2021-01-10T20:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710445#M37964</link>
      <description>I get this error message : No observations were selected from data set MORIS.TEST_NOTIFICATION_DATA.&lt;BR /&gt;NOTE: There were 0 observations read from the data set MORIS.TEST_NOTIFICATION_DATA.. Any thoughts why this could be ? Thanks</description>
      <pubDate>Sun, 10 Jan 2021 14:01:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710445#M37964</guid>
      <dc:creator>Hiandbye</dc:creator>
      <dc:date>2021-01-10T14:01:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710446#M37965</link>
      <description>&lt;P&gt;Please post the complete log from your step.&lt;/P&gt;
&lt;P&gt;And get to know your data (types and formats of variables, retrieved with PROC CONTENTS), so you better know how to code the WHERE.&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 14:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710446#M37965</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-01-10T14:18:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710462#M37966</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357957"&gt;@Hiandbye&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/357957"&gt;@Hiandbye&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;I get this error message : No observations were selected from data set MORIS.TEST_NOTIFICATION_DATA.&lt;BR /&gt;NOTE: There were 0 observations read from the data set MORIS.TEST_NOTIFICATION_DATA.. Any thoughts why this could be ? Thanks&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You need to use a condition which is appropriate for the &lt;EM&gt;contents&lt;/EM&gt; of the variable in question and, of course, the correct &lt;EM&gt;variable name&lt;/EM&gt;&amp;nbsp;(i.e., "know your data"&amp;nbsp; -- &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068" target="_blank" rel="noopener"&gt;Maxim 3&lt;/A&gt;). In your initial post you mentioned &lt;SPAN&gt;&lt;FONT face="courier new,courier"&gt;Date_Received&lt;/FONT&gt; as the variable name, in your code you used &lt;FONT face="courier new,courier"&gt;dt_rec&lt;/FONT&gt; and&amp;nbsp;&lt;/SPAN&gt;the "dates" in your screenshot are headed "&lt;FONT face="courier new,courier"&gt;Last_Run&lt;/FONT&gt;" and are in fact &lt;EM&gt;datetimes&lt;/EM&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example: If variable&amp;nbsp;&lt;FONT face="courier new,courier"&gt;dt_rec&lt;/FONT&gt; contains SAS datetimes from the past and you want to select those which are up to 7 days old, more precisely: today (10 Jan 2021) those from 03JAN2021:00:00:00 or later, an appropriate WHERE statement for your PROC FREQ step is:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;where dt_rec&amp;gt;=intnx('dtdays',datetime(),-7);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;(See the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetVersion=9.4&amp;amp;docsetTarget=p10v3sa3i4kfxfn1sovhi5xzxh8n.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;documentation of the INTNX function&lt;/A&gt; for more details and options.)&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 17:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710462#M37966</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2021-01-10T17:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710470#M37967</link>
      <description>Good shout thanks! It worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Sun, 10 Jan 2021 20:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710470#M37967</guid>
      <dc:creator>Hiandbye</dc:creator>
      <dc:date>2021-01-10T20:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the  usage  within two dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710471#M37968</link>
      <description>&lt;P&gt;Thanks ! Proc contents will be my ally from now on &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 20:16:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-find-the-usage-within-two-dates/m-p/710471#M37968</guid>
      <dc:creator>Hiandbye</dc:creator>
      <dc:date>2021-01-10T20:16:03Z</dc:date>
    </item>
  </channel>
</rss>

