<?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: Help with first. and last. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738834#M230524</link>
    <description>&lt;P&gt;&lt;SPAN&gt;Scenario 2)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input (DATE1         DATE2     ) (:date11.);
format date: date9.;
cards;
20-Apr-21   1-Jan-21  31-Dec-99
20-Apr-21   1-Jan-21  31-Dec-99
20-Apr-21   1-Jan-21  31-Jan-00
20-Apr-21   1-Jan-21  31-Dec-99
20-Apr-21   1-Jul-19   31-Dec-20
20-Apr-21   1-Jul-19   31-Dec-20
27-Apr-21   1-Jul-19   31-Dec-20
28-Apr-21   1-Jul-19   31-Dec-20
29-Apr-21   1-Jul-19   31-Dec-20
;
data temp;
  set have;
  by date1 date2  notsorted;
  if first.date1 then group=0;
  group+first.date2;
run;
proc sql;
create table want as
select *
 from temp
  group by date1
   having count(distinct group)&amp;gt;1 and group=1;
quit;&lt;/PRE&gt;</description>
    <pubDate>Tue, 04 May 2021 10:18:43 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2021-05-04T10:18:43Z</dc:date>
    <item>
      <title>Help with first. and last.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738751#M230489</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Need help with below&lt;/P&gt;&lt;P&gt;DATE1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DATE2&amp;nbsp; &amp;nbsp; &amp;nbsp;DATE3&lt;BR /&gt;20-Apr-21&amp;nbsp; &amp;nbsp;1-Jan-21&amp;nbsp; 31-Dec-99&lt;BR /&gt;20-Apr-21&amp;nbsp; &amp;nbsp;1-Jan-21&amp;nbsp; 31-Dec-99&lt;BR /&gt;20-Apr-21&amp;nbsp; &amp;nbsp;1-Jan-21&amp;nbsp; 31-Jan-00&lt;BR /&gt;20-Apr-21&amp;nbsp; &amp;nbsp;1-Jan-21&amp;nbsp; 31-Dec-99&lt;BR /&gt;20-Apr-21&amp;nbsp; &amp;nbsp;1-Jul-19&amp;nbsp; &amp;nbsp;31-Dec-20&lt;BR /&gt;20-Apr-21&amp;nbsp; &amp;nbsp;1-Jul-19&amp;nbsp; &amp;nbsp;31-Dec-20&lt;BR /&gt;27-Apr-21&amp;nbsp; &amp;nbsp;1-Jul-19&amp;nbsp; &amp;nbsp;31-Dec-20&lt;BR /&gt;28-Apr-21&amp;nbsp; &amp;nbsp;1-Jul-19&amp;nbsp; &amp;nbsp;31-Dec-20&lt;BR /&gt;29-Apr-21&amp;nbsp; &amp;nbsp;1-Jul-19&amp;nbsp; &amp;nbsp;31-Dec-20&lt;/P&gt;&lt;P&gt;All the three dates were sorted&lt;BR /&gt;Scenario-1)&lt;BR /&gt;If DATE1 is not changed, DAT2 is not changed and only DATE3 has changed, I need those rows&lt;BR /&gt;That means first two rows&lt;BR /&gt;Scenario 2)&lt;BR /&gt;Suppose DATE3 doesn't exists&lt;BR /&gt;Now I need to get only first 4 rows of DATE1 and DATE2, as there is a change starting in DATE2, in row5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 00:34:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738751#M230489</guid>
      <dc:creator>West26</dc:creator>
      <dc:date>2021-05-04T00:34:13Z</dc:date>
    </item>
    <item>
      <title>Re: Help with first. and last.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738762#M230491</link>
      <description>&lt;OL&gt;
&lt;LI&gt;Please provide your initial data in the form of a working data step.&amp;nbsp; Save us some time by doing this task.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Please provide your expected data as a result of the rule.&amp;nbsp; I ask this because you specify (&lt;EM&gt;&lt;STRONG&gt;bold italics mine&lt;/STRONG&gt;&lt;/EM&gt;)&amp;nbsp;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;Scenario-1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If DATE1 is not changed, DAT2 is not changed and only DATE3 has changed, I need those rows&lt;/SPAN&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;That means first two rows&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The first two rows are constant for all 3 dates, so how is it that you want the first two rows given the rule you state ("only DATE3 has changes)?&lt;BR /&gt;&lt;BR /&gt;Do you really mean you want all the rows &lt;EM&gt;&lt;STRONG&gt;preceding&lt;/STRONG&gt;&lt;/EM&gt; a change in date3?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 02:37:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738762#M230491</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-05-04T02:37:23Z</dc:date>
    </item>
    <item>
      <title>Re: Help with first. and last.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738827#M230519</link>
      <description>&lt;P&gt;Scenario-1)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input (DATE1         DATE2     DATE3) (:date11.);
format date: date9.;
cards;
20-Apr-21   1-Jan-21  31-Dec-99
20-Apr-21   1-Jan-21  31-Dec-99
20-Apr-21   1-Jan-21  31-Jan-00
20-Apr-21   1-Jan-21  31-Dec-99
20-Apr-21   1-Jul-19   31-Dec-20
20-Apr-21   1-Jul-19   31-Dec-20
27-Apr-21   1-Jul-19   31-Dec-20
28-Apr-21   1-Jul-19   31-Dec-20
29-Apr-21   1-Jul-19   31-Dec-20
;
data temp;
  set have;
  by date1 date2 date3 notsorted;
  if first.date2 then group=0;
  group+first.date3;
run;
proc sql;
create table want as
select *
 from temp
  group by date1,date2
   having count(distinct group)&amp;gt;1 and group=1;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 May 2021 10:14:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738827#M230519</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-04T10:14:43Z</dc:date>
    </item>
    <item>
      <title>Re: Help with first. and last.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738828#M230520</link>
      <description>&lt;P&gt;Thanks for your time and the suggestion. Appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;input custid date1 :yymmdd10. date2 :yymmdd10. date3 :yymmdd10.&lt;BR /&gt;format date1 yymmdd10. date2 yymmdd10. date3 yymmdd10.;&lt;BR /&gt;datalines;&lt;BR /&gt;1 20/04/2021 01/01/2021 31/12/1999&lt;BR /&gt;2 20/04/2021 01/01/2021 31/12/1999&lt;BR /&gt;3 20/04/2021 01/01/2021 31/01/2000&lt;BR /&gt;4 20/04/2021 01/01/2021 31/12/1999&lt;BR /&gt;5 20/04/2021 01/07/2021 31/12/2000&lt;BR /&gt;6 20/04/2021 01/07/2021 31/12/2000&lt;BR /&gt;7 27/04/2021 01/07/2021 31/12/2000&lt;BR /&gt;8 28/04/2021 01/07/2021 31/12/2000&lt;BR /&gt;9 29/04/2021 01/07/2021 31/12/2000&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Scenario:&lt;BR /&gt;1) I want all the rows, preceding a change in date3, like below&lt;BR /&gt;Output:&lt;BR /&gt;1 20/04/2021 01/01/2021 31/12/1999&lt;BR /&gt;2 20/04/2021 01/01/2021 31/12/1999&lt;/P&gt;&lt;P&gt;2) Suppose DATE3 doesn't exists&lt;BR /&gt;I want all the rows, preceding a change in DATE2, like below&lt;BR /&gt;Output:&lt;BR /&gt;1 20/04/2021 01/01/2021&lt;BR /&gt;2 20/04/2021 01/01/2021&lt;BR /&gt;3 20/04/2021 01/01/2021&lt;BR /&gt;4 20/04/2021 01/01/2021&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 10:11:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738828#M230520</guid>
      <dc:creator>West26</dc:creator>
      <dc:date>2021-05-04T10:11:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help with first. and last.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738830#M230521</link>
      <description>Hi Ksharp,&lt;BR /&gt;I'm unable to see anything here.</description>
      <pubDate>Tue, 04 May 2021 10:13:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738830#M230521</guid>
      <dc:creator>West26</dc:creator>
      <dc:date>2021-05-04T10:13:01Z</dc:date>
    </item>
    <item>
      <title>Re: Help with first. and last.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738834#M230524</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Scenario 2)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
input (DATE1         DATE2     ) (:date11.);
format date: date9.;
cards;
20-Apr-21   1-Jan-21  31-Dec-99
20-Apr-21   1-Jan-21  31-Dec-99
20-Apr-21   1-Jan-21  31-Jan-00
20-Apr-21   1-Jan-21  31-Dec-99
20-Apr-21   1-Jul-19   31-Dec-20
20-Apr-21   1-Jul-19   31-Dec-20
27-Apr-21   1-Jul-19   31-Dec-20
28-Apr-21   1-Jul-19   31-Dec-20
29-Apr-21   1-Jul-19   31-Dec-20
;
data temp;
  set have;
  by date1 date2  notsorted;
  if first.date1 then group=0;
  group+first.date2;
run;
proc sql;
create table want as
select *
 from temp
  group by date1
   having count(distinct group)&amp;gt;1 and group=1;
quit;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 May 2021 10:18:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-first-and-last/m-p/738834#M230524</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-05-04T10:18:43Z</dc:date>
    </item>
  </channel>
</rss>

