<?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: deleting observations... in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations/m-p/78569#M256451</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use two do loops. One to find the first missing value and the second to clear out the end of the array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; array x x1-x5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do i=1 to dim(x) while (not missing(x(i))); end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do i=i to dim(x); x(i)=.; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Apr 2012 04:53:14 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2012-04-11T04:53:14Z</dc:date>
    <item>
      <title>deleting observations...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations/m-p/78568#M256450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have a quick question on how to delete observations. &lt;/P&gt;&lt;P&gt;Say I have a data set as following:&lt;/P&gt;&lt;P&gt;data example;&lt;/P&gt;&lt;P&gt;input y x1 x2 x3 x4 x5;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;5 1 2 3 . 5&lt;/P&gt;&lt;P&gt;2 4 . . 6 8&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to delete rest of the observations after the first encounter of a missing value. For example I want the following result. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;5 1 2 3 . .&lt;/P&gt;&lt;P&gt;2 4 . . . .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What would the code look like?&lt;/P&gt;&lt;P&gt;I tried using do loop with delete statement but it didn't quite work. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;array x{5} x1 x2 x3 x4 x5;&lt;/P&gt;&lt;P&gt;do i=1 to 5;&lt;/P&gt;&lt;P&gt;if x&lt;I&gt;=. then delete x&lt;I&gt; to x[5];&lt;/I&gt;&lt;/I&gt;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 04:10:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations/m-p/78568#M256450</guid>
      <dc:creator>zehross</dc:creator>
      <dc:date>2012-04-11T04:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations/m-p/78569#M256451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could use two do loops. One to find the first missing value and the second to clear out the end of the array.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; array x x1-x5;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do i=1 to dim(x) while (not missing(x(i))); end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp; do i=i to dim(x); x(i)=.; end;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 04:53:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations/m-p/78569#M256451</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2012-04-11T04:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: deleting observations...</title>
      <link>https://communities.sas.com/t5/SAS-Programming/deleting-observations/m-p/78570#M256452</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Or one array do loop:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data example;&lt;/P&gt;&lt;P&gt;input y x1 x2 x3 x4 x5;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;5 1 2 3 . 5&lt;/P&gt;&lt;P&gt;2 4 . . 6 8&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;set example;&lt;/P&gt;&lt;P&gt;array v y x1-x5;&lt;/P&gt;&lt;P&gt;do _n_=1 to dim(v)-1;&lt;/P&gt;&lt;P&gt;if _n_ &amp;lt; dim(v) then if missing(v(_n_)) then call missing (v(_n_+1));&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kindly Regards,&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Apr 2012 13:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/deleting-observations/m-p/78570#M256452</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-04-11T13:43:03Z</dc:date>
    </item>
  </channel>
</rss>

