<?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: Historical observations based on dates in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302610#M20522</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start='01jan2016'd;
%let end=%sysfunc(date());

proc sql;
select count(*) from have
where start &amp;lt; &amp;amp;end and (end &amp;gt; &amp;amp;start or end = .)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you don't need extra variables.&lt;/P&gt;</description>
    <pubDate>Wed, 05 Oct 2016 12:47:15 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2016-10-05T12:47:15Z</dc:date>
    <item>
      <title>Historical observations based on dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302601#M20521</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm relatively new to SAS, have completed a beginner&amp;nbsp;a course on EG 6.1&amp;nbsp;and Miner.&amp;nbsp;&amp;nbsp; I've looked around the forum but don't seem to find&amp;nbsp;a solution to a specific problem I'm faced with.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have&amp;nbsp;imported a dataset, say&amp;nbsp;contract dates. Each observation has a start date, and an end date&amp;nbsp;if the contract was terminated.&amp;nbsp; I&amp;nbsp;want to count the number of&amp;nbsp;observations (active and/or ended)&amp;nbsp;on different time frames, f.i. last 60 months, and create&amp;nbsp;an overview like a summary table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs&amp;nbsp;&amp;nbsp; Start&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan 1, 2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; March 15, 2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; April 20, 2012&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; October 4, 2013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;October 4, 2015&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only method I currently see is to create a computed column that compares the observation start/end date to the reference date (1: active on date or during period, 0: inactive) and then summarizing it,&amp;nbsp; but this would mean having to create dozens of computed columns&amp;nbsp;with fixed reference dates to build up&amp;nbsp;a history.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Obs&amp;nbsp;&amp;nbsp; Start&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan 1, 2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Nov 1, 2015&lt;/P&gt;&lt;P&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Jan 1, 2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; March 15, 2010&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; April 20, 2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; October 4, 2013&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;October 4, 2015&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm struggling to find an easier solution&amp;nbsp;in SAS EG.&amp;nbsp;Can someone point me in the right direction or a similar&amp;nbsp;topic&amp;nbsp;on how to handle this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 12:27:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302601#M20521</guid>
      <dc:creator>LeroyA</dc:creator>
      <dc:date>2016-10-05T12:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Historical observations based on dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302610#M20522</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let start='01jan2016'd;
%let end=%sysfunc(date());

proc sql;
select count(*) from have
where start &amp;lt; &amp;amp;end and (end &amp;gt; &amp;amp;start or end = .)
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So you don't need extra variables.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 12:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302610#M20522</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-10-05T12:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: Historical observations based on dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302631#M20524</link>
      <description>&lt;P&gt;Thank you for the quick reply, Kurt.&amp;nbsp;&amp;nbsp;&amp;nbsp;SAS programming is still very new to me.&amp;nbsp; I'll try to&amp;nbsp;find out what&amp;nbsp;that code&amp;nbsp;does and how to use it before&amp;nbsp;posting a new question.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Oct 2016 13:13:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302631#M20524</guid>
      <dc:creator>LeroyA</dc:creator>
      <dc:date>2016-10-05T13:13:43Z</dc:date>
    </item>
    <item>
      <title>Re: Historical observations based on dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302711#M20535</link>
      <description>You could do this in the Query Builder. But with this short SQL it's probably easier just to use the SQL as a program...</description>
      <pubDate>Wed, 05 Oct 2016 15:55:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302711#M20535</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2016-10-05T15:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Historical observations based on dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302828#M20536</link>
      <description>&lt;PRE&gt;

It should be easy for SQL.

CODE NOT TESTED.

proc sql;
select count(*) as n_active 
 from have
   having start is not missing and end is missing and
              start ge intnx('month',today(),-60,'s');

select count(*) as n_end 
 from have
   having start is not missing and end is not missing and
              start ge intnx('month',today(),-60,'s');
quit;

&lt;/PRE&gt;</description>
      <pubDate>Thu, 06 Oct 2016 03:20:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302828#M20536</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-10-06T03:20:59Z</dc:date>
    </item>
    <item>
      <title>Re: Historical observations based on dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302878#M20541</link>
      <description>&lt;P&gt;I&amp;nbsp;tried to&amp;nbsp;adapt&amp;nbsp;your codes and apply it on my database. It runs without errors and returns a result:&amp;nbsp;a single number for Kurt's code and 3 million+ identical&amp;nbsp;totals for KSharp's code.&amp;nbsp; But as I require a comprehensive overview with much&amp;nbsp;more detail (such as evolutions by month by different categories such as geography, age....) , I don't think I will be able to work this out in coding yet with the limited knowledge I have.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm&amp;nbsp;totally new to programming, even&amp;nbsp;SQL is&amp;nbsp;not very common to me.&amp;nbsp;I'm basically an end-user with&amp;nbsp;limited IT knowledge. It was told that EG&amp;nbsp;does not require any&amp;nbsp;knowledge of coding, but almost every solution offered on various questions in the forum comes down to coding. So I guess I'll need to take a course&amp;nbsp;on&amp;nbsp;that...&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, thank you for your time and suggestions!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2016 09:09:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302878#M20541</guid>
      <dc:creator>LeroyA</dc:creator>
      <dc:date>2016-10-06T09:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Historical observations based on dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302881#M20543</link>
      <description>&lt;P&gt;SAS EG has a Point &amp;amp; Click interface which allows you to get quite a few things done without any coding (the UI actually generates the code in the background).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A lot of the people here in this forum are "coders". You need to specifically ask how things could be done with EG point &amp;amp; click if you need such an answer.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When things become more complicated though then you'll reach the limit of point &amp;amp; click and you need to code and if you have some coding skills then also using the point &amp;amp; click option becomes more powerfull&amp;nbsp;as sometimes you can ingest code blocks (functions, formats etc.) which opens up additional possibilities for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So yes, absolutely, go for training. There are recommended learning&amp;nbsp;paths depending on where you come from and want to&amp;nbsp;be&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://support.sas.com/training/us/paths/&amp;nbsp;" target="_blank"&gt;https://support.sas.com/training/us/paths/&amp;nbsp;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2016 09:28:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302881#M20543</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2016-10-06T09:28:39Z</dc:date>
    </item>
    <item>
      <title>Re: Historical observations based on dates</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302995#M20551</link>
      <description>&lt;P&gt;It will also help if show the desired final output, not just that of what you think an intermediate data set should look like.&lt;/P&gt;
&lt;P&gt;Sometimes you can find that the Reporting procedures are very powerful for creating complex summaries. Though usually more than 3 or 4 rows of data may be needed.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Oct 2016 17:21:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Historical-observations-based-on-dates/m-p/302995#M20551</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-10-06T17:21:07Z</dc:date>
    </item>
  </channel>
</rss>

