<?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 last three obs in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599976#M173302</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Experts Good Morning&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here i&amp;nbsp; have a class dataset from that&amp;nbsp; i want to retrieve last three observations&amp;nbsp;&lt;/P&gt;&lt;P&gt;what if how many observations in a data set then how to get last three observations&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*if we do not know how many obs in a dataset then how we get last 3 records*/
data ds10;
do i=nobs to 1 ;
set sashelp.class point=i nobs=nobs;
output;
end;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Oct 2019 05:14:30 GMT</pubDate>
    <dc:creator>BrahmanandaRao</dc:creator>
    <dc:date>2019-10-29T05:14:30Z</dc:date>
    <item>
      <title>last three obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599976#M173302</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Experts Good Morning&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here i&amp;nbsp; have a class dataset from that&amp;nbsp; i want to retrieve last three observations&amp;nbsp;&lt;/P&gt;&lt;P&gt;what if how many observations in a data set then how to get last three observations&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*if we do not know how many obs in a dataset then how we get last 3 records*/
data ds10;
do i=nobs to 1 ;
set sashelp.class point=i nobs=nobs;
output;
end;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 05:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599976#M173302</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-10-29T05:14:30Z</dc:date>
    </item>
    <item>
      <title>Re: last three obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599977#M173303</link>
      <description>&lt;P&gt;With what do you have to replace the "1" here&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = nobs to 1 by -1;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to only get three observations? Play around with it.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 05:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599977#M173303</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-29T05:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: last three obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599978#M173304</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;do i = nobs to 1 by -1;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;just come reverse order only but i want last three records&lt;/P&gt;&lt;P&gt;and how to do unknown observations in a dataset&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 05:25:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599978#M173304</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-10-29T05:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: last three obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599988#M173310</link>
      <description>&lt;P&gt;You already know the number of observations in the dataset (nobs). So just count up from nobs - 2, or don't use point= at all, and just output when _n_ reaches your threshold.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 06:26:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599988#M173310</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-29T06:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: last three obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599992#M173313</link>
      <description>&lt;P&gt;Sorry not understand&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 06:54:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599992#M173313</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-10-29T06:54:15Z</dc:date>
    </item>
    <item>
      <title>Re: last three obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599993#M173314</link>
      <description>&lt;P&gt;You know the total number of observations in your dataset (that's what the nobs= option does).&lt;/P&gt;
&lt;P&gt;The &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lrcon&amp;amp;docsetTarget=p0e0mk25gs9binn1s9jiu4otau29.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;automatic variable _N_&lt;/A&gt; provided by SAS holds the number of data step iterations, so in a simple data step it gives you the number of the current observation read. By comparing _N_ to nobs - 3 in a &lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lestmtsref&amp;amp;docsetTarget=p1cxl8ifdt8u0gn12wqbji8o5fq1.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;subsetting if&lt;/A&gt;, you can achieve what you want.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 07:13:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599993#M173314</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-29T07:13:04Z</dc:date>
    </item>
    <item>
      <title>Re: last three obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599996#M173315</link>
      <description>&lt;P&gt;Sir&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here it is correct output&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*if we do not know how many obs in a dataset then how we get last 3 records*/
data ds10;
do i=nobs-2 to nobs;
set sashelp.class nobs=nobs point=i;
output;
end;
stop;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Oct 2019 07:26:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599996#M173315</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-10-29T07:26:50Z</dc:date>
    </item>
    <item>
      <title>Re: last three obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599997#M173316</link>
      <description>&lt;P&gt;Alternatively, with a subsetting if:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ds10;
set sashelp.class nobs=nobs;
if _n_ &amp;gt; nobs - 3;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;With larger datasets and small subsets, the point= will perform better.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 07:42:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/599997#M173316</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-10-29T07:42:51Z</dc:date>
    </item>
    <item>
      <title>Re: last three obs</title>
      <link>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/600000#M173318</link>
      <description>&lt;P&gt;Thank You sir&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For your quick response and advise&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Oct 2019 08:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/last-three-obs/m-p/600000#M173318</guid>
      <dc:creator>BrahmanandaRao</dc:creator>
      <dc:date>2019-10-29T08:07:56Z</dc:date>
    </item>
  </channel>
</rss>

