<?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: how to show last month dataset only in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-show-last-month-dataset-only/m-p/502577#M134180</link>
    <description>&lt;P&gt;Please give a skeleton program.&amp;nbsp; I don't know what you mean by "exit".&amp;nbsp; Do you mean end the sas session?&amp;nbsp; Skip some other program steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editted note.&amp;nbsp; Here's something close to what I think you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsname=op.abc_%sysfunc(intnx(month,%sysfunc(today()),-1),yymmn6.);

%macro existds(name);
  %if %sysfunc(exist(&amp;amp;name)) %then 1;
  %else 0
%mend existds;
%put Dataset &amp;amp;dsname exist dummy is %existds(&amp;amp;dsname);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The main thing here is, given today's date, constructing the data set name corresponding to last month (op.abc_201809).&amp;nbsp; Above it's constructed in macro language.&amp;nbsp; In a data step, it would look something&amp;nbsp;like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  dsname=cats('op.abc_',put(intnx('month',today(),-1),yymmn6.));
  d=exist(dsname);
  put d=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 09 Oct 2018 04:10:30 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2018-10-09T04:10:30Z</dc:date>
    <item>
      <title>how to show last month dataset only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-show-last-month-dataset-only/m-p/502573#M134177</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can any one help me&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have library name called 'op' in the library i have a datasets looks like&lt;/P&gt;&lt;P&gt;abc_201301&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201302&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201303&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201304&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201801&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201802&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201803&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201804&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201805&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201806&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201807&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201808&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;abc_201809&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;till the last month&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;ex:if i ran a program the dataset today, it will create this year lastmonth(201809)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;How can i show only last month dataset name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if the last month dataset is created show only last month dataset name ,if not created it should exit&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 03:24:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-show-last-month-dataset-only/m-p/502573#M134177</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-10-09T03:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: how to show last month dataset only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-show-last-month-dataset-only/m-p/502577#M134180</link>
      <description>&lt;P&gt;Please give a skeleton program.&amp;nbsp; I don't know what you mean by "exit".&amp;nbsp; Do you mean end the sas session?&amp;nbsp; Skip some other program steps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Editted note.&amp;nbsp; Here's something close to what I think you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let dsname=op.abc_%sysfunc(intnx(month,%sysfunc(today()),-1),yymmn6.);

%macro existds(name);
  %if %sysfunc(exist(&amp;amp;name)) %then 1;
  %else 0
%mend existds;
%put Dataset &amp;amp;dsname exist dummy is %existds(&amp;amp;dsname);

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The main thing here is, given today's date, constructing the data set name corresponding to last month (op.abc_201809).&amp;nbsp; Above it's constructed in macro language.&amp;nbsp; In a data step, it would look something&amp;nbsp;like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  dsname=cats('op.abc_',put(intnx('month',today(),-1),yymmn6.));
  d=exist(dsname);
  put d=;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Oct 2018 04:10:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-show-last-month-dataset-only/m-p/502577#M134180</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-10-09T04:10:30Z</dc:date>
    </item>
    <item>
      <title>Re: how to show last month dataset only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-show-last-month-dataset-only/m-p/502578#M134181</link>
      <description>If the current year previous month dataset is not present then it stop the&lt;BR /&gt;searching the dataset and come out of the loop&lt;BR /&gt;</description>
      <pubDate>Tue, 09 Oct 2018 04:19:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-show-last-month-dataset-only/m-p/502578#M134181</guid>
      <dc:creator>SRINIVAS_N</dc:creator>
      <dc:date>2018-10-09T04:19:13Z</dc:date>
    </item>
    <item>
      <title>Re: how to show last month dataset only</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-show-last-month-dataset-only/m-p/502580#M134183</link>
      <description>&lt;P&gt;What loop?&amp;nbsp; Please show the code that implements the loop.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2018 04:25:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-show-last-month-dataset-only/m-p/502580#M134183</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-10-09T04:25:11Z</dc:date>
    </item>
  </channel>
</rss>

