<?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: Unusual result with FIRSTOBS and OBS option with WHERE statement in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946977#M370794</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/420483"&gt;@Nipun22&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Can you please elaborate?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What needs elaboration? What is not clear in my previous reply?&lt;/P&gt;</description>
    <pubDate>Thu, 10 Oct 2024 13:34:12 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2024-10-10T13:34:12Z</dc:date>
    <item>
      <title>Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946967#M370790</link>
      <description>&lt;P&gt;Main code with problem&lt;/P&gt;
&lt;PRE&gt;proc print data=SASHELP.CLASS(firstobs=5 obs=15);
where Sex='M';
run;&lt;/PRE&gt;
&lt;P&gt;So the general meaning of the above program is that observations whose sex is 'Male' will starting reading from 5th record and stops at 15th record but instead SAS starts reading from 10th record and goes all the way to the end of the dataset up to 19th record. So, what is there I am missing here because I don't get the logic here at all?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SASHELP.CLASS dataset for reference&lt;/P&gt;
&lt;PRE&gt;proc print data=sashelp.class;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nipun22_1-1728566000485.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101094i5CF7ABAD4002B57A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Nipun22_1-1728566000485.png" alt="Nipun22_1-1728566000485.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nipun22_2-1728566015150.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101095iFDE819FB230FB1EA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Nipun22_2-1728566015150.png" alt="Nipun22_2-1728566015150.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 13:22:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946967#M370790</guid>
      <dc:creator>Nipun22</dc:creator>
      <dc:date>2024-10-10T13:22:27Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946969#M370791</link>
      <description>&lt;P&gt;The PROC PRINT starts at the 5th male record and continues to the 15th male record (which doesn't exist).&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 13:26:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946969#M370791</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-10T13:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946972#M370793</link>
      <description>Can you please elaborate?</description>
      <pubDate>Thu, 10 Oct 2024 13:27:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946972#M370793</guid>
      <dc:creator>Nipun22</dc:creator>
      <dc:date>2024-10-10T13:27:45Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946977#M370794</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/420483"&gt;@Nipun22&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Can you please elaborate?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What needs elaboration? What is not clear in my previous reply?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 13:34:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946977#M370794</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-10T13:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946982#M370795</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068/show-comments/false" target="_self"&gt;Maxim #1: Read the doc.&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/lrcon/9.4/n1iok7aawea9zzn1aso4ulosip7l.htm" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/lrcon/9.4/n1iok7aawea9zzn1aso4ulosip7l.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;WHERE takes precedence over OBS= and FIRSTOBS=.&lt;/P&gt;
&lt;P&gt;If you comment out "OBS" part like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc print data=SASHELP.CLASS/*(firstobs=5 obs=15)*/;
where Sex='M';
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the result will be:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1728567364293.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101103i9C2B11948D4A6C3B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1728567364293.png" alt="yabwon_0-1728567364293.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;And in the original (not commented-out code) this is the moment where FIRSTOBS=5 starts working, that is why you get:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_1-1728567470554.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/101104iA78E563AA4710D11/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_1-1728567470554.png" alt="yabwon_1-1728567470554.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;and since there are less then 15 obs selected by the WHERE clause, you get them all.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 13:44:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946982#M370795</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-10-10T13:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946995#M370799</link>
      <description>So it means that SAS will create a subset of the dataset using the where statement and then it will run firstobs and obs.&lt;BR /&gt;Also if the subset of the main dataset had more than 15 records then it would have stopped reading on 15th record? right?</description>
      <pubDate>Thu, 10 Oct 2024 14:12:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946995#M370799</guid>
      <dc:creator>Nipun22</dc:creator>
      <dc:date>2024-10-10T14:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946999#M370800</link>
      <description>&lt;P&gt;yes, exactly.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 14:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/946999#M370800</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2024-10-10T14:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/947000#M370801</link>
      <description>&lt;P&gt;This type of question has actually been around for 40 years, ever since the WHERE statement was invented.&amp;nbsp; Either interpretation seems reasonable:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Consider observations 5 through 15, and select only the males&lt;/LI&gt;
&lt;LI&gt;Consider only the males, and of those take the 5th through the 15th&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;In fact, originally SAS couldn't decide which interpretation to use.&amp;nbsp; For a year or two, using WHERE when OBS/FIRSTOBS was in effect would generate an error message.&amp;nbsp; Finally SAS decided that the second interpretation would be the more useful one.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 14:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/947000#M370801</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2024-10-10T14:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/947001#M370802</link>
      <description>&lt;P&gt;that's quite interesting! thanks for telling &lt;BR /&gt;Although i was hesitating initially to ask questions related on simple concepts like where statement etc but it seems it was logical.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Oct 2024 14:48:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/947001#M370802</guid>
      <dc:creator>Nipun22</dc:creator>
      <dc:date>2024-10-10T14:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Unusual result with FIRSTOBS and OBS option with WHERE statement</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/947049#M370810</link>
      <description>&lt;DIV class="lia-quilt-row lia-quilt-row-main"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-24 lia-quilt-column-single lia-quilt-column-main"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-single"&gt;
&lt;DIV class="forum-topic-flex-article"&gt;
&lt;DIV class="forum-article"&gt;
&lt;DIV class="forum-post"&gt;
&lt;DIV id="bodyDisplay_15cf017e47f123" class="lia-message-body lia-component-message-view-widget-body lia-component-body-signature-highlight-escalation lia-component-message-view-widget-body-signature-highlight-escalation"&gt;
&lt;DIV class="lia-message-body-content"&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;try answering like this someday that will be more helpful&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="lia-quilt-row lia-quilt-row-footer"&gt;
&lt;DIV class="lia-quilt-column lia-quilt-column-24 lia-quilt-column-single lia-quilt-column-message-footer"&gt;
&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-single"&gt;
&lt;DIV class="message-actions-shelf"&gt;
&lt;DIV class="message-extra"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 Oct 2024 19:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Unusual-result-with-FIRSTOBS-and-OBS-option-with-WHERE-statement/m-p/947049#M370810</guid>
      <dc:creator>Nipun22</dc:creator>
      <dc:date>2024-10-10T19:00:11Z</dc:date>
    </item>
  </channel>
</rss>

