<?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: Keep first and last row in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/379299#M91293</link>
    <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; durga;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Sub &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Date:&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;yymmdd10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Phase $ &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;24&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;infile&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; datalines;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;01 2016-06-06 Before&lt;/P&gt;&lt;P&gt;01 2016-06-24 During&lt;/P&gt;&lt;P&gt;01 2016-07-01 During&lt;/P&gt;&lt;P&gt;01 2016-08-19 During&lt;/P&gt;&lt;P&gt;01 2016-08-26 After&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=durga &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=class;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Phase;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; durga_;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; class;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; phase;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; first.Phase=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; or last.phase=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2017 09:18:32 GMT</pubDate>
    <dc:creator>Saidurga1</dc:creator>
    <dc:date>2017-07-26T09:18:32Z</dc:date>
    <item>
      <title>Keep first and last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300394#M63438</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following row of data:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Sub &amp;nbsp; Date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Phase&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;01 &amp;nbsp; &amp;nbsp; 2016-06-06 &amp;nbsp; &amp;nbsp; &amp;nbsp;Before&lt;/P&gt;
&lt;P&gt;01 &amp;nbsp; &amp;nbsp; 2016-06-24 &amp;nbsp; &amp;nbsp; &amp;nbsp;During&lt;/P&gt;
&lt;P&gt;01 &amp;nbsp; &amp;nbsp; 2016-07-01 &amp;nbsp; &amp;nbsp; &amp;nbsp;During&lt;/P&gt;
&lt;P&gt;01 &amp;nbsp; &amp;nbsp; 2016-08-19 &amp;nbsp; &amp;nbsp; &amp;nbsp;During&lt;/P&gt;
&lt;P&gt;01 &amp;nbsp; &amp;nbsp; 2016-08-26 &amp;nbsp; &amp;nbsp; &amp;nbsp;After&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to keep the first and last During to have the data look like this:&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Sub &amp;nbsp; Date &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Phase&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;01 &amp;nbsp; &amp;nbsp; 2016-06-06 &amp;nbsp; &amp;nbsp; &amp;nbsp;Before&lt;/P&gt;
&lt;P&gt;01 &amp;nbsp; &amp;nbsp; 2016-06-24 &amp;nbsp; &amp;nbsp; &amp;nbsp;During&lt;/P&gt;
&lt;P&gt;01 &amp;nbsp; &amp;nbsp; 2016-08-19 &amp;nbsp; &amp;nbsp; &amp;nbsp;During&lt;/P&gt;
&lt;P&gt;01 &amp;nbsp; &amp;nbsp; 2016-08-26 &amp;nbsp; &amp;nbsp; &amp;nbsp;After&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to use the first. and last variable like below:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DATA JR.SV_021;&lt;BR /&gt;SET SV_02;&lt;BR /&gt;BY PHASE;&lt;BR /&gt;IF first.PHASE THEN OUTPUT;&lt;BR /&gt;IF last.PHASE THEN OUTPUT;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but it does not work for me. &amp;nbsp;I appreciate your help very much 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>Fri, 23 Sep 2016 14:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300394#M63438</guid>
      <dc:creator>zz</dc:creator>
      <dc:date>2016-09-23T14:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Keep first and last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300398#M63442</link>
      <description>&lt;P&gt;A small change should get this to work. &amp;nbsp;Change the BY statement to:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BY PHASE NOTSORTED;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That will permit your BY statement even though the data are not in order by Phase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note, if your actual data set is larger and might contain more than one SUB value, you may need to use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BY SUB PHASE NOTSORTED;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Either way, the rest of the program can remain the same.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 14:52:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300398#M63442</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-09-23T14:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Keep first and last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300407#M63446</link>
      <description>&lt;P&gt;Tried, but somehow, it did not work:(&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 15:14:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300407#M63446</guid>
      <dc:creator>zz</dc:creator>
      <dc:date>2016-09-23T15:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Keep first and last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300409#M63448</link>
      <description>&lt;P&gt;Describe how "doesn't work": Error, unexpected output, no output.&lt;/P&gt;
&lt;P&gt;And show the code ran and the log.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 15:18:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300409#M63448</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-23T15:18:13Z</dc:date>
    </item>
    <item>
      <title>Re: Keep first and last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300413#M63449</link>
      <description>&lt;P&gt;Hi ballardw, It worked! &amp;nbsp;I checked and one libref was not correct for input data. &amp;nbsp;Once that's corrected, it all worked. &amp;nbsp;Thank you very much!&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 15:35:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300413#M63449</guid>
      <dc:creator>zz</dc:creator>
      <dc:date>2016-09-23T15:35:44Z</dc:date>
    </item>
    <item>
      <title>Re: Keep first and last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300433#M63453</link>
      <description>&lt;P&gt;Hi ballardw,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One problem, rows are duplicated, if phase changed in&amp;nbsp;the next row, eg: the first row was duplicated.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 16:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300433#M63453</guid>
      <dc:creator>zz</dc:creator>
      <dc:date>2016-09-23T16:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Keep first and last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300438#M63456</link>
      <description>&lt;P&gt;Replace&lt;/P&gt;
&lt;P&gt;IF last.PHASE THEN OUTPUT;&lt;/P&gt;
&lt;P&gt;with&lt;/P&gt;
&lt;P&gt;IF last.PHASE and not (First.Phase) THEN OUTPUT&lt;/P&gt;</description>
      <pubDate>Fri, 23 Sep 2016 16:44:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/300438#M63456</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-09-23T16:44:39Z</dc:date>
    </item>
    <item>
      <title>Re: Keep first and last row</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/379299#M91293</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; durga;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Sub &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;2.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; Date:&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;yymmdd10.&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Phase $ &lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;24&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;-&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;30&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;infile&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; datalines;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;01 2016-06-06 Before&lt;/P&gt;&lt;P&gt;01 2016-06-24 During&lt;/P&gt;&lt;P&gt;01 2016-07-01 During&lt;/P&gt;&lt;P&gt;01 2016-08-19 During&lt;/P&gt;&lt;P&gt;01 2016-08-26 After&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sort&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=durga &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=class;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Phase;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; durga_;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; class;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; phase;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;if&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; first.Phase=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt; or last.phase=&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="2"&gt;1&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2017 09:18:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Keep-first-and-last-row/m-p/379299#M91293</guid>
      <dc:creator>Saidurga1</dc:creator>
      <dc:date>2017-07-26T09:18:32Z</dc:date>
    </item>
  </channel>
</rss>

