<?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: Dynamic way of fetching Last 50 observations from dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947276#M370852</link>
    <description>&lt;P&gt;Try this code:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data second_dataset;&lt;BR /&gt;set sashelp.shoes nobs=the_count;&lt;BR /&gt;if _N_ &amp;gt; the_count -50;&lt;BR /&gt;run;&lt;/P&gt;</description>
    <pubDate>Sun, 13 Oct 2024 16:08:11 GMT</pubDate>
    <dc:creator>Bala_Saladi</dc:creator>
    <dc:date>2024-10-13T16:08:11Z</dc:date>
    <item>
      <title>Dynamic way of fetching Last 50 observations from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947274#M370850</link>
      <description>Every time I am using proc contents to view total number of obervations in a dataset, then I am using dataset option to create secondary dataset of last 50 observations.&lt;BR /&gt;What is the pice of code to make my code dynamic for this everyday task.</description>
      <pubDate>Sun, 13 Oct 2024 16:01:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947274#M370850</guid>
      <dc:creator>Flowerbud</dc:creator>
      <dc:date>2024-10-13T16:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic way of fetching Last 50 observations from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947275#M370851</link>
      <description>&lt;P&gt;First find the number of observations in the data set, put it into a macro variable called NOBS.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Determining-the-number-of-observations-in-a-SAS-data-set/ta-p/475174" target="_blank" rel="noopener"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Determining-the-number-of-observations-in-a-SAS-data-set/ta-p/475174&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
     set have(firstobs=%eval(&amp;amp;nobs-49));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Oct 2024 16:09:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947275#M370851</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-10-13T16:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic way of fetching Last 50 observations from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947276#M370852</link>
      <description>&lt;P&gt;Try this code:-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data second_dataset;&lt;BR /&gt;set sashelp.shoes nobs=the_count;&lt;BR /&gt;if _N_ &amp;gt; the_count -50;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Oct 2024 16:08:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947276#M370852</guid>
      <dc:creator>Bala_Saladi</dc:creator>
      <dc:date>2024-10-13T16:08:11Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic way of fetching Last 50 observations from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947277#M370853</link>
      <description>Thank you for your solution! I am new to SAS software, still learning advanced programming skills on macros.</description>
      <pubDate>Sun, 13 Oct 2024 16:35:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947277#M370853</guid>
      <dc:creator>Flowerbud</dc:creator>
      <dc:date>2024-10-13T16:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic way of fetching Last 50 observations from dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947278#M370854</link>
      <description>&lt;P&gt;Note that FIRSTOBS= option expects an integer larger than 0.&lt;/P&gt;
&lt;P&gt;So if you would need a little more logic to get it right.&lt;/P&gt;
&lt;P&gt;Something like:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let nobs=19;
%let n=10;
%let firstobs=%sysfunc(max(1,&amp;amp;nobs-&amp;amp;n+1));
%put &amp;amp;=nobs &amp;amp;=n &amp;amp;=firstobs;
data want;
  set sashelp.class(firstobs=&amp;amp;firstobs);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Oct 2024 17:00:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-way-of-fetching-Last-50-observations-from-dataset/m-p/947278#M370854</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-10-13T17:00:41Z</dc:date>
    </item>
  </channel>
</rss>

