<?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: first and last observation in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555369#M154558</link>
    <description>Hi KurtBremser,&lt;BR /&gt;thanks for the explanation it's to valuable information&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; regards&lt;BR /&gt;rohitkrishna</description>
    <pubDate>Wed, 01 May 2019 14:46:12 GMT</pubDate>
    <dc:creator>rohitkrishna</dc:creator>
    <dc:date>2019-05-01T14:46:12Z</dc:date>
    <item>
      <title>sas mainframe</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555359#M154553</link>
      <description>&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;I got stuck at one point of my sas code it all about&amp;nbsp; to retrieve only first and last record of my dataset&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried in multiple ways in sas and SQL I succeed in SQL by using max and min statements in the code but till&amp;nbsp; now I didn't get in sas&lt;/P&gt;&lt;P&gt;so kindly guide the current code for fetch only 2 records that are first and last record&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in sas i tried&lt;STRONG&gt; &lt;FONT color="#FFFF00"&gt;&lt;FONT color="#000000"&gt;if _n_ = 1&lt;/FONT&gt;;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;but i got only first rec i want the last one too&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;&lt;P&gt;Thnaks &amp;amp; regards&amp;nbsp;&lt;/P&gt;&lt;P&gt;rohitkrishna&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 13:55:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555359#M154553</guid>
      <dc:creator>rohitkrishna</dc:creator>
      <dc:date>2019-05-01T13:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: first and last observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555360#M154554</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have (obs=1);
output;
set have point=nobs nobs=nobs;
output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2019 13:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555360#M154554</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-01T13:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: first and last observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555364#M154556</link>
      <description>Hi KurtBremser,&lt;BR /&gt;thanks for the quick replay and the code works successfully and I have a query on code&lt;BR /&gt;could you plz explain the statement has below mention&lt;BR /&gt;{set have point=nobs nobs=nobs;}&lt;BR /&gt;Thanks &amp;amp; regards&lt;BR /&gt;rohitkrishna</description>
      <pubDate>Wed, 01 May 2019 14:19:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555364#M154556</guid>
      <dc:creator>rohitkrishna</dc:creator>
      <dc:date>2019-05-01T14:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: first and last observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555366#M154557</link>
      <description>&lt;P&gt;nobs=nobs creates a variable (which will not be included in the output) that holds the total number of observations in the dataset. point=nobs uses this variable to retrieve only this last observation.&lt;/P&gt;
&lt;P&gt;Since the first statement creates the necessary end-of-file condition to end the data step, no explicit stop statement is needed.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 14:34:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555366#M154557</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-05-01T14:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: first and last observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555369#M154558</link>
      <description>Hi KurtBremser,&lt;BR /&gt;thanks for the explanation it's to valuable information&lt;BR /&gt;&lt;BR /&gt;Thanks &amp;amp; regards&lt;BR /&gt;rohitkrishna</description>
      <pubDate>Wed, 01 May 2019 14:46:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555369#M154558</guid>
      <dc:creator>rohitkrishna</dc:creator>
      <dc:date>2019-05-01T14:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: first and last observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555404#M154565</link>
      <description>&lt;P&gt;Just to cover the boundary condition that there is one and only one observation in the source dataset add and IF .&lt;/P&gt;
&lt;P&gt;Otherwise the result will have the same observation twice.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
  set have (obs=1);
  output;
  if nobs&amp;gt;1;
  set have point=nobs nobs=nobs;
  output;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2019 16:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555404#M154565</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-01T16:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: first and last observation</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555406#M154566</link>
      <description>&lt;P&gt;Also if you cannot use the NOBS= and/or the POINT= option (perhaps your input is a VIEW instead of dataset) then here is method that will read the whole file and just keep the first and last observation.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
 set sashelp.class end=eof;
 if _n_=1 or eof;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2019 16:47:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sas-mainframe/m-p/555406#M154566</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-05-01T16:47:22Z</dc:date>
    </item>
  </channel>
</rss>

