<?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 LAG Function for grouping dates in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/LAG-Function-for-grouping-dates/m-p/730009#M227264</link>
    <description>&lt;P&gt;&lt;FONT size="2"&gt;Good day everyone,&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hope you are well.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Please can you assist with a LAG"ging" problem...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;This is what I &lt;STRONG&gt;want&lt;/STRONG&gt; to &lt;STRONG&gt;achieve&lt;/STRONG&gt; excluding the&amp;nbsp;&lt;EM&gt;DatecreatedID - the last 2 columns&amp;nbsp; (this data is attached)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;MonthKey EmployeeKey Staff_Indi MonthsOfService EngagementDate &lt;EM&gt;DatecreatedID&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;STRONG&gt; DateFrom&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DateTo&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201003&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 56&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20100401&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005/07/01&amp;nbsp; &amp;nbsp; 2010/04/01&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201011&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 64&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20101103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010/04/02&amp;nbsp; &amp;nbsp; &amp;nbsp;2010/11/03&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201405&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 106&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20140501&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010/11/04&amp;nbsp; &amp;nbsp; &amp;nbsp;2014/05/01&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201611&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 136&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20161101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2014/05/02&amp;nbsp; &amp;nbsp; &amp;nbsp;2016/11/01&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201702&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 139&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20170201&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2016/11/02&amp;nbsp; &amp;nbsp; &amp;nbsp;2017/02/01&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201709&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 146&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20170902&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2017/02/02&amp;nbsp; &amp;nbsp; &amp;nbsp;2017/09/02&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;In SQL we have the following code to retrieve this data and my problem is the last few lines of code that have been bolded is a LAG Function which I cannot convert to SAS coding.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The last 2 columns are defrived from the&amp;nbsp;&lt;EM&gt;DatecreatedID&amp;nbsp; - the date that something changed on EEs profile. This is a varchar which is converted into a date.&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;When this code is run, the first DateFrom pops up as Null for the first employee, but for the 2nd it is correct again pulling the engagementdate&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;select fc.MonthKey&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, '1234567' as EmployeeKey&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, Case When fc.Headcount = 1 then 'Yes' &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; When fc.Headcount = 0 then 'No' Else 'Unknown' end as 'Staff_Indi'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, fc.MonthsOfService&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt; &amp;nbsp; /* PRE CALCULATED MONTHS OF SERVICE */&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, fc.CompanyEngagementDateID as 'EngagementDate'&amp;nbsp; &lt;EM&gt;&amp;nbsp;/* DATE EMPLOYEE STARTED WITH THE FIRM */&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, fcec.DatecreatedID&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;EM&gt; &amp;nbsp;/* DATE THE EMPLOYEE PROFILE CHANGED */&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;, Case When (DateAdd(day,1,convert(date,convert(varchar(8),(LAG(fcec.DatecreatedID) over (Order By e.employeekey, fcec.DatecreatedID))))) &amp;gt;= convert(date,convert(varchar(8),fc.DatecreatedID ))) Then convert(date,convert(varchar(8),fc.EngagementDateID ))&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Else DateAdd(day,1,convert(date,convert(varchar(8),(LAG(fcec.DatecreatedID) over (Order By e.employeekey, fcec.DatecreatedID))))) End as DateFrom&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;, convert(date,convert(varchar(8),fcec.DatecreatedID )) as DateTo&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Will appreciate assistance with this.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thanks &amp;amp; have a great day.&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Mar 2021 08:44:43 GMT</pubDate>
    <dc:creator>ColleenCB</dc:creator>
    <dc:date>2021-03-30T08:44:43Z</dc:date>
    <item>
      <title>LAG Function for grouping dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LAG-Function-for-grouping-dates/m-p/730009#M227264</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Good day everyone,&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Hope you are well.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Please can you assist with a LAG"ging" problem...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;This is what I &lt;STRONG&gt;want&lt;/STRONG&gt; to &lt;STRONG&gt;achieve&lt;/STRONG&gt; excluding the&amp;nbsp;&lt;EM&gt;DatecreatedID - the last 2 columns&amp;nbsp; (this data is attached)&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;MonthKey EmployeeKey Staff_Indi MonthsOfService EngagementDate &lt;EM&gt;DatecreatedID&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;STRONG&gt; DateFrom&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DateTo&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201003&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 56&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20100401&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2005/07/01&amp;nbsp; &amp;nbsp; 2010/04/01&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201011&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 64&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20101103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010/04/02&amp;nbsp; &amp;nbsp; &amp;nbsp;2010/11/03&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201405&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 106&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20140501&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2010/11/04&amp;nbsp; &amp;nbsp; &amp;nbsp;2014/05/01&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201611&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 136&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20161101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2014/05/02&amp;nbsp; &amp;nbsp; &amp;nbsp;2016/11/01&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201702&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 139&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20170201&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2016/11/02&amp;nbsp; &amp;nbsp; &amp;nbsp;2017/02/01&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;201709&amp;nbsp; &amp;nbsp; &amp;nbsp;1234567&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Yes&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 146&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20050701&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 20170902&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2017/02/02&amp;nbsp; &amp;nbsp; &amp;nbsp;2017/09/02&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;In SQL we have the following code to retrieve this data and my problem is the last few lines of code that have been bolded is a LAG Function which I cannot convert to SAS coding.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;The last 2 columns are defrived from the&amp;nbsp;&lt;EM&gt;DatecreatedID&amp;nbsp; - the date that something changed on EEs profile. This is a varchar which is converted into a date.&amp;nbsp;&amp;nbsp;&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;EM&gt;When this code is run, the first DateFrom pops up as Null for the first employee, but for the 2nd it is correct again pulling the engagementdate&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;select fc.MonthKey&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, '1234567' as EmployeeKey&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, Case When fc.Headcount = 1 then 'Yes' &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; When fc.Headcount = 0 then 'No' Else 'Unknown' end as 'Staff_Indi'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, fc.MonthsOfService&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;EM&gt; &amp;nbsp; /* PRE CALCULATED MONTHS OF SERVICE */&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, fc.CompanyEngagementDateID as 'EngagementDate'&amp;nbsp; &lt;EM&gt;&amp;nbsp;/* DATE EMPLOYEE STARTED WITH THE FIRM */&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;, fcec.DatecreatedID&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;EM&gt; &amp;nbsp;/* DATE THE EMPLOYEE PROFILE CHANGED */&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;, Case When (DateAdd(day,1,convert(date,convert(varchar(8),(LAG(fcec.DatecreatedID) over (Order By e.employeekey, fcec.DatecreatedID))))) &amp;gt;= convert(date,convert(varchar(8),fc.DatecreatedID ))) Then convert(date,convert(varchar(8),fc.EngagementDateID ))&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;Else DateAdd(day,1,convert(date,convert(varchar(8),(LAG(fcec.DatecreatedID) over (Order By e.employeekey, fcec.DatecreatedID))))) End as DateFrom&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;STRONG&gt;, convert(date,convert(varchar(8),fcec.DatecreatedID )) as DateTo&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Will appreciate assistance with this.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Thanks &amp;amp; have a great day.&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 08:44:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LAG-Function-for-grouping-dates/m-p/730009#M227264</guid>
      <dc:creator>ColleenCB</dc:creator>
      <dc:date>2021-03-30T08:44:43Z</dc:date>
    </item>
    <item>
      <title>Re: LAG Function for grouping dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LAG-Function-for-grouping-dates/m-p/730011#M227265</link>
      <description>&lt;P&gt;Please supply your data in usable form (data step with datalines, posted in a code box).&lt;/P&gt;
&lt;P&gt;Excel files tell us nothing about SAS variable types and attributes.&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 08:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LAG-Function-for-grouping-dates/m-p/730011#M227265</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-03-30T08:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: LAG Function for grouping dates</title>
      <link>https://communities.sas.com/t5/SAS-Programming/LAG-Function-for-grouping-dates/m-p/730102#M227302</link>
      <description>&lt;P&gt;LAG does not generally work in SAS Proc SQL, so you need to show the entire procedure code you are attempting so we have a chance of understanding what you are trying to accomplish.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this is pass through to another DBMS we need that information as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since "Lag" is intended to look at a previous record then the first record does not have a previous so should return missing.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many users here don't want to download Excel files because of virus potential, others have such things blocked by security software. Also if you give us Excel we have to create a SAS data set and due to the non-existent constraints on Excel data cells the result we end up with may not have variables of the same type (numeric or character) and even values.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Mar 2021 14:24:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/LAG-Function-for-grouping-dates/m-p/730102#M227302</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-30T14:24:16Z</dc:date>
    </item>
  </channel>
</rss>

