<?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: proc contents on last dataset by name and date in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-contents-on-last-dataset-by-name-and-date/m-p/808703#M318885</link>
    <description>&lt;P&gt;Last by which date? The date in the name? The creation date? The modified date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you might find this code of interest. Replace 'WORK' with the name of your Library in upper case. This creates a table with an X at the intersection of variable name and type and data set name. It is often useful to know that the same named variable occurs as both character and numeric. If you really want to you could add the other characteristics of variables such as Label, format or length but that may be disheartening if find lots of differences for same-named variables.&lt;/P&gt;
&lt;PRE&gt;proc format;
value x
.=' '
other='X'
;
run;
proc tabulate data=sashelp.vcolumn;
   where libname='WORK' and memtype='DATA';
   class name memname type;
   table name*type,
         memname*n=' '*f=x.
         /misstext=' '
   ;
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 19 Apr 2022 23:12:16 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-04-19T23:12:16Z</dc:date>
    <item>
      <title>proc contents on last dataset by name and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-contents-on-last-dataset-by-name-and-date/m-p/808691#M318874</link>
      <description>&lt;P&gt;Lets say I have a libname called myfiles with the contents as follows:&lt;/P&gt;
&lt;P&gt;acct_cd_20210401&lt;/P&gt;
&lt;P&gt;acct_cd_20210412&lt;/P&gt;
&lt;P&gt;cof_fod_20200419&lt;/P&gt;
&lt;P&gt;cof_fod_20220411&lt;/P&gt;
&lt;P&gt;mrt_ftr_20200402&lt;/P&gt;
&lt;P&gt;mrt_ftr_20220418&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to do a proc contents on the last dataset in each category by name and date only (ie&amp;nbsp;acct_cd_20210412,cof_fod_20220411,mrt_ftr_20220418)&lt;/P&gt;
&lt;P&gt;proc contents data=myfiles. ????????&lt;/P&gt;
&lt;P&gt;I want to get the names of fields in the tables however I do not want to have to do a proc contents on each and every table name.&amp;nbsp; Can such a query be done?&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 22:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-contents-on-last-dataset-by-name-and-date/m-p/808691#M318874</guid>
      <dc:creator>Q1983</dc:creator>
      <dc:date>2022-04-19T22:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: proc contents on last dataset by name and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-contents-on-last-dataset-by-name-and-date/m-p/808695#M318878</link>
      <description>&lt;P&gt;Look at the SASHELP.VCOLUMN or dictionary.column table which contains the metadata for tables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can filter by the library easily. There is also a creation date but you'll need to add a column to separate your date into the date portion and prefix of the table name and then select only the records of interest.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/5629"&gt;@Q1983&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Lets say I have a libname called myfiles with the contents as follows:&lt;/P&gt;
&lt;P&gt;acct_cd_20210401&lt;/P&gt;
&lt;P&gt;acct_cd_20210412&lt;/P&gt;
&lt;P&gt;cof_fod_20200419&lt;/P&gt;
&lt;P&gt;cof_fod_20220411&lt;/P&gt;
&lt;P&gt;mrt_ftr_20200402&lt;/P&gt;
&lt;P&gt;mrt_ftr_20220418&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to do a proc contents on the last dataset in each category by name and date only (ie&amp;nbsp;acct_cd_20210412,cof_fod_20220411,mrt_ftr_20220418)&lt;/P&gt;
&lt;P&gt;proc contents data=myfiles. ????????&lt;/P&gt;
&lt;P&gt;I want to get the names of fields in the tables however I do not want to have to do a proc contents on each and every table name.&amp;nbsp; Can such a query be done?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2022 22:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-contents-on-last-dataset-by-name-and-date/m-p/808695#M318878</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-04-19T22:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc contents on last dataset by name and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-contents-on-last-dataset-by-name-and-date/m-p/808703#M318885</link>
      <description>&lt;P&gt;Last by which date? The date in the name? The creation date? The modified date?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Perhaps you might find this code of interest. Replace 'WORK' with the name of your Library in upper case. This creates a table with an X at the intersection of variable name and type and data set name. It is often useful to know that the same named variable occurs as both character and numeric. If you really want to you could add the other characteristics of variables such as Label, format or length but that may be disheartening if find lots of differences for same-named variables.&lt;/P&gt;
&lt;PRE&gt;proc format;
value x
.=' '
other='X'
;
run;
proc tabulate data=sashelp.vcolumn;
   where libname='WORK' and memtype='DATA';
   class name memname type;
   table name*type,
         memname*n=' '*f=x.
         /misstext=' '
   ;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Apr 2022 23:12:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-contents-on-last-dataset-by-name-and-date/m-p/808703#M318885</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-19T23:12:16Z</dc:date>
    </item>
    <item>
      <title>Re: proc contents on last dataset by name and date</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-contents-on-last-dataset-by-name-and-date/m-p/808710#M318890</link>
      <description>&lt;P&gt;Get this list of MEMBERs in the library.&amp;nbsp; Strip off the numeric suffix.&amp;nbsp; Sort by the remaining text.&amp;nbsp; Take the last (or first) one.&lt;/P&gt;
&lt;P&gt;Let's test it.&amp;nbsp; First let's make some datasets with those names.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data acct_cd_20210401 acct_cd_20210412 cof_fod_20200419 cof_fod_20220411 mrt_ftr_20200402 mrt_ftr_20220418;
  set sashelp.class(obs=1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now make the ordered list.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql ;
create table list as 
  select catx('.',libname,memname) as dsname
       , substr(memname,1,length(memname)-8) as basename
       , scan(memname,-1,'_') as suffix
  from dictionary.members 
  where libname='WORK'
    and not missing(input(scan(memname,-1,'_'),?yymmdd8.))
  order by 2,3
;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now pick the last (latest) one for each basename and generate PROC CONTENT code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set list;
  by basename;
  if last.basename;
  call execute(catx(' ','proc contents data=',dsname,';run;'));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 19 Apr 2022 23:22:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-contents-on-last-dataset-by-name-and-date/m-p/808710#M318890</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-04-19T23:22:59Z</dc:date>
    </item>
  </channel>
</rss>

