<?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: READ only first and last obs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/READ-only-first-and-last-obs/m-p/750578#M236118</link>
    <description>&lt;P&gt;The first SET statement reads the first observation from the source table as you're used to it. The OUTPUT statement then writes this row to the target table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the first statement there is also keyword &lt;EM&gt;nobs=_nobs_&lt;/EM&gt;&amp;nbsp;&lt;BR /&gt;This stores the total number of observations in variable _nobs_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second SET statement then uses direct access via keyword&lt;EM&gt; point=_nobs_&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This reads the observation number stored in _nobs_ from the source table - and with _nobs_ containing the total number of observations this is going to be the very last observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the last statement STOP then instructs SAS to not further iterate through the data.&lt;/P&gt;</description>
    <pubDate>Sat, 26 Jun 2021 05:52:36 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2021-06-26T05:52:36Z</dc:date>
    <item>
      <title>READ only first and last obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/READ-only-first-and-last-obs/m-p/750577#M236117</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I want to&amp;nbsp;&lt;SPAN&gt;select first and last row of a data set.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I saw this code that say that in the case that data set is very big then we can tell SAS to read only first and last rows.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;May anyone explian this code?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;I know NOBS option in SET.&lt;/P&gt;
&lt;P&gt;But I dont understand how this code work and how SAS knows to read only first and last observations.&lt;/P&gt;
&lt;P&gt;What is the meaning of "STOP" in this code?&lt;/P&gt;
&lt;P&gt;What is the meaning of "OUTPUT" in this code?&lt;/P&gt;
&lt;P&gt;Why using 2 SET statements?&lt;/P&gt;
&lt;P&gt;What is POINT var?&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data first_last_rows;
set SASHELP.cars nobs=_nobs_;
output;
set SASHELP.cars  point=_nobs_;
output;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 05:44:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/READ-only-first-and-last-obs/m-p/750577#M236117</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2021-06-26T05:44:33Z</dc:date>
    </item>
    <item>
      <title>Re: READ only first and last obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/READ-only-first-and-last-obs/m-p/750578#M236118</link>
      <description>&lt;P&gt;The first SET statement reads the first observation from the source table as you're used to it. The OUTPUT statement then writes this row to the target table.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the first statement there is also keyword &lt;EM&gt;nobs=_nobs_&lt;/EM&gt;&amp;nbsp;&lt;BR /&gt;This stores the total number of observations in variable _nobs_;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The second SET statement then uses direct access via keyword&lt;EM&gt; point=_nobs_&lt;/EM&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This reads the observation number stored in _nobs_ from the source table - and with _nobs_ containing the total number of observations this is going to be the very last observation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And the last statement STOP then instructs SAS to not further iterate through the data.&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 05:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/READ-only-first-and-last-obs/m-p/750578#M236118</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-06-26T05:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: READ only first and last obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/READ-only-first-and-last-obs/m-p/750581#M236119</link>
      <description>&lt;P&gt;You could even eliminate the STOP statement by using the (obs=1) dataset name parameter, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data first_last_rows;
  set SASHELP.cars (obs=1) ;
  output;
  set SASHELP.cars  point=_nobs_ nobs=_nobs_;
  output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Jun 2021 06:47:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/READ-only-first-and-last-obs/m-p/750581#M236119</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2021-06-26T06:47:08Z</dc:date>
    </item>
    <item>
      <title>Re: READ only first and last obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/READ-only-first-and-last-obs/m-p/750596#M236128</link>
      <description>&lt;P&gt;If the input dataset has only one observation it will be output twice.&amp;nbsp; Do you want that?&lt;/P&gt;</description>
      <pubDate>Sat, 26 Jun 2021 12:07:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/READ-only-first-and-last-obs/m-p/750596#M236128</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-06-26T12:07:12Z</dc:date>
    </item>
  </channel>
</rss>

