<?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: Delete First/Last observation from multiple EU's in a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144609#M261895</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The syntax is FIRST.variablename not Variablename.first. When you used the dot notation the compiler went looking for some special instruction/behavior named ID which doesn't exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you might want consider if you want to delete if there is only one record. In that case First.id and Last.id are the same and it would be deleted.&lt;/P&gt;&lt;P&gt;You can provide an additional test for&lt;/P&gt;&lt;P&gt;If first.id and last.id then &amp;lt;whatever&amp;gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 29 Jan 2015 20:06:36 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2015-01-29T20:06:36Z</dc:date>
    <item>
      <title>Delete First/Last observation from multiple EU's in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144606#M261892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to figure out how I would remove the first and last observation from a data set with Multiple EU's with 30-40 observations from each EU in chronological order.&amp;nbsp;&amp;nbsp; How would I remove the first time and last time?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 19:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144606#M261892</guid>
      <dc:creator>dandvm</dc:creator>
      <dc:date>2015-01-29T19:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: Delete First/Last observation from multiple EU's in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144607#M261893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;Order your dataset and use .first and .last&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if myvar.first OR myvar.last delete;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 19:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144607#M261893</guid>
      <dc:creator>morgalr</dc:creator>
      <dc:date>2015-01-29T19:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Delete First/Last observation from multiple EU's in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144608#M261894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; ID.first &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;delete&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is what I get&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;ERROR: DATA STEP Component Object failure.&amp;nbsp; Aborted during the COMPILATION phase.&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;ERROR 557-185: Variable ID is not an object.&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;What does this mean?&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: Courier;"&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 19:55:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144608#M261894</guid>
      <dc:creator>dandvm</dc:creator>
      <dc:date>2015-01-29T19:55:23Z</dc:date>
    </item>
    <item>
      <title>Re: Delete First/Last observation from multiple EU's in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144609#M261895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The syntax is FIRST.variablename not Variablename.first. When you used the dot notation the compiler went looking for some special instruction/behavior named ID which doesn't exist.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you might want consider if you want to delete if there is only one record. In that case First.id and Last.id are the same and it would be deleted.&lt;/P&gt;&lt;P&gt;You can provide an additional test for&lt;/P&gt;&lt;P&gt;If first.id and last.id then &amp;lt;whatever&amp;gt;;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 20:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144609#M261895</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-01-29T20:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: Delete First/Last observation from multiple EU's in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144610#M261896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I initially thought that this was correct.&amp;nbsp; However, I used the follow code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New';"&gt;&lt;SPAN style="color: #0433ff;"&gt;if&lt;/SPAN&gt; first.ID &lt;SPAN style="color: #0433ff;"&gt;then&lt;/SPAN&gt; &lt;SPAN style="color: #0433ff;"&gt;delete&lt;/SPAN&gt;;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;if&lt;SPAN style="color: #000000;"&gt; last.id &lt;/SPAN&gt;then&lt;SPAN style="color: #000000;"&gt; &lt;/SPAN&gt;delete&lt;SPAN style="color: #000000;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 10px; font-family: 'Courier New'; color: #0433ff;"&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-size: 8pt;"&gt;It didn't actually do anything.&amp;nbsp; No records were removed.&amp;nbsp; I have something still wrong here.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-size: 8pt;"&gt;Thanks&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: 'Courier New'; font-size: 8pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 20:41:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144610#M261896</guid>
      <dc:creator>dandvm</dc:creator>
      <dc:date>2015-01-29T20:41:04Z</dc:date>
    </item>
    <item>
      <title>Re: Delete First/Last observation from multiple EU's in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144611#M261897</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think you may need to post a bit more of the code used.&lt;/P&gt;&lt;P&gt;Also, did you have a BY statement? Without that it will not work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by ID;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if first.ID or last.ID then delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 20:45:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144611#M261897</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-01-29T20:45:33Z</dc:date>
    </item>
    <item>
      <title>Re: Delete First/Last observation from multiple EU's in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144612#M261898</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ballardw,&lt;/P&gt;&lt;P&gt;yes, quite right: I always get the order of the first/last mixed up with the variable--too much object oriented programming--and indeed it does remove any that only have a singular observation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is the corrected code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data myEdit;&lt;/P&gt;&lt;P&gt;set test;&lt;/P&gt;&lt;P&gt;by myID;&lt;/P&gt;&lt;P&gt;if (first.myID or last.myID) then delete;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And here is the code with that extra bit, it only strips the first and last, but it will also leave the observation that is a single for the id:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data myJunk;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set test;&lt;/P&gt;&lt;P&gt;&amp;nbsp; by myID;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if (not (first.myID and last.myID)) and (first.myID or last.myID) then delete;&lt;/P&gt;&lt;P&gt; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Jan 2015 21:41:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Delete-First-Last-observation-from-multiple-EU-s-in-a-dataset/m-p/144612#M261898</guid>
      <dc:creator>morgalr</dc:creator>
      <dc:date>2015-01-29T21:41:02Z</dc:date>
    </item>
  </channel>
</rss>

