<?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: search a data set name in the server in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467598#M119369</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datasetxyz_20180602;
set sashelp.class;
run;

proc sql noprint;
    SELECT MEMNAME
    INTO :dsname
    FROM dictionary.tables
    WHERE LIBNAME="WORK" AND MEMNAME LIKE cats("DATASETXYZ_",put(today(),yymmn6.),"%");
quit;

%put &amp;amp;dsname.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Jun 2018 08:27:56 GMT</pubDate>
    <dc:creator>gamotte</dc:creator>
    <dc:date>2018-06-05T08:27:56Z</dc:date>
    <item>
      <title>search a data set name in the server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467595#M119367</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would have to use a dataset that is provided by another unit. last part of the dataset name(day part) changes each month, and rest stays the same. such as&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;datasetxyz_20180523&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;datasetxyz_20180630&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;datasetxyz_20180710&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I want my code to pick up the correct dataset when I run. If I am running on 2018 may, it should grab the dataset --&amp;gt; datasetxyz_20180523.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help me how to achieve this.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks in advance&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, 05 Jun 2018 08:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467595#M119367</guid>
      <dc:creator>Myurathan</dc:creator>
      <dc:date>2018-06-05T08:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: search a data set name in the server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467597#M119368</link>
      <description>&lt;P&gt;Why should it pick up that one for 2018?&amp;nbsp; Is it always the first.&amp;nbsp; As a recommendation, which will be ignored, putting data - in this case a date - in dataset names will only lead to far harder programming to handle it.&amp;nbsp; One dataset with date as a column is so much simpler to work with from any angle, its then just a matter of&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;where date_var="23May2018"d;&lt;/PRE&gt;
&lt;P&gt;As it is, now your going to have to write code which delves in the metadata, converts the various information, then pulls the right file out.&amp;nbsp; Factoring up your work, the code you write, and the likelihood that it will fail 10 fold.&lt;/P&gt;
&lt;P&gt;Maybe something like:&lt;/P&gt;
&lt;PRE&gt;data inter;
  set sashelp.vtable where=(libname="&amp;lt;YOURLIB&amp;gt;" and substr(memname,1,10)="DATASETXYZ"));
  d_var=input(scan(memname,2,"_"),yymmdd8.);
  where year(d_var)=2018;
run;
proc sort data=inter;
  by d_var;
run;&lt;BR /&gt;data inter;&lt;BR /&gt;  set inter;&lt;BR /&gt;  if _n_=1;&lt;BR /&gt;run;&lt;/PRE&gt;
&lt;P&gt;So this gets a list of datasets from a library which you need to specify (all uppercase), with that dataset prefix, gets the date part from the filename, and converts to a date, keeping only year 2018.&amp;nbsp; Then it sorts the data with earliest first and finally takes the first record.&amp;nbsp; All that code just because of a design choice, madness.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 08:20:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467597#M119368</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-06-05T08:20:46Z</dc:date>
    </item>
    <item>
      <title>Re: search a data set name in the server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467598#M119369</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data datasetxyz_20180602;
set sashelp.class;
run;

proc sql noprint;
    SELECT MEMNAME
    INTO :dsname
    FROM dictionary.tables
    WHERE LIBNAME="WORK" AND MEMNAME LIKE cats("DATASETXYZ_",put(today(),yymmn6.),"%");
quit;

%put &amp;amp;dsname.;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Jun 2018 08:27:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467598#M119369</guid>
      <dc:creator>gamotte</dc:creator>
      <dc:date>2018-06-05T08:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: search a data set name in the server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467599#M119370</link>
      <description>&lt;P&gt;Query dictionary.tables:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let libname=mylib;
%let dsname=datasetxyz_;
%let period=201805;

proc sql;
select memname into :memname from dictionary.tables
where substr(memname,1,length("&amp;amp;dsname&amp;amp;period")) = upcase("&amp;amp;dsname&amp;amp;period") and libname = upcase("&amp;amp;libname");
quit;

data want;
set &amp;amp;libname..&amp;amp;memname;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 08:35:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467599#M119370</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-06-05T08:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: search a data set name in the server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467601#M119371</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt; You are truly amazing. Thank you so much</description>
      <pubDate>Tue, 05 Jun 2018 08:57:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467601#M119371</guid>
      <dc:creator>Myurathan</dc:creator>
      <dc:date>2018-06-05T08:57:23Z</dc:date>
    </item>
    <item>
      <title>Re: search a data set name in the server</title>
      <link>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467609#M119374</link>
      <description>&lt;P&gt;If you only get one dataset per month, there is a fast and dirty solution. Just wildcard the day part with a colon:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%let month=201806;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;/* or perhaps: %let month=%sysfunc(date(),yymmn6.); */&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;Data want&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&amp;nbsp; set &amp;lt;libname&amp;gt;.datasetxyz_&amp;amp;month: ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course, if you get more than one dataset each month, this will read all of the datasets for the month. Which may not be what you want.&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jun 2018 10:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/search-a-data-set-name-in-the-server/m-p/467609#M119374</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-06-05T10:23:52Z</dc:date>
    </item>
  </channel>
</rss>

