<?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: Assign macro variable value by extracting date from dataset name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196102#M36841</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One thing I forgot to mention, and why you might want to create a data set of dates, is that, you risk the 'last' data set not being the latest data set.&lt;/P&gt;&lt;P&gt;This might happen by virtue of the the collating sequeence of 'yyyymmdd' not being in sync with the date. So you could create the data set as above, then sort it, and then pick off the last date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SORT DATA=x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by dt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput () ... as above&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this makes sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 06 Mar 2015 14:35:56 GMT</pubDate>
    <dc:creator>rcwright</dc:creator>
    <dc:date>2015-03-06T14:35:56Z</dc:date>
    <item>
      <title>Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196096#M36835</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have following datasets in my library:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;libname.Assistance_20150101&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;libname.Assistance_20150102&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;libname.Assistance_20150103&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;libname.Assistance_20150104&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;libname.Assistance_20150105&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;libname.Assistance_20150222&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;libname.Assistance_20150223&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;I need to write a macro which should return a macro variable whose value should be based on the last dataset name. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;STRONG&gt;(Example: if A is a macro variable &amp;amp; the last dataset available in the library &lt;SPAN style="text-decoration: underline;"&gt;(based on creation date)&lt;/SPAN&gt; is &lt;SPAN style="font-size: 13.3333330154419px;"&gt;libname.Assistance_20150223, then value of A should be 20150223)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Apart from macro, if the above result can be achived with some other method(s), then please do share your thoughts.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 07:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196096#M36835</guid>
      <dc:creator>KP12</dc:creator>
      <dc:date>2015-03-06T07:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196097#M36836</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Firstly, and most importantly, I wouldn't recommend this approach.&amp;nbsp; Macro variables are text strings and to work with dates (which are numeric representations of an ad-hoc strcuture) means complicated code with lots of ampersands, and functions.&amp;nbsp; It gets messy and is dreadfull to try to use.&amp;nbsp; There are many other posts on this type of thing on this site.&amp;nbsp; &lt;/P&gt;&lt;P&gt;Secondly, if you need to keep an audit history of your data, I wouldn't recommend having datasets with dates in the name.&amp;nbsp; This may seem like a workable method but ultimately it will get unweildy and will not encompass changes which occur later on.&amp;nbsp; A simple example is what will you do when (and it most likely is when even if not forseen) you have two datasets on the same date?&amp;nbsp; I would recommend looking into either a) software version control, e.g. TortoiseSVN - this will keep history behind the scenes and you only have to deal with one dataset with a fixed name, or b) journalling, - such as is done in OC where data is recieved and changes from base copy are stored in a journal (i.e. audit history).&amp;nbsp; With either of these routes you would have a datetime stamp which would address the multiples on same date, and because there is only one dataset or journal, it makes further updating far easier than having to change several datasets and easier to QC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now if you ignore all the above and continue, you can look at the dataset names in sashelp.vtable:&lt;/P&gt;&lt;P&gt;data test;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set sashelp.vtable (where=(libname="LIBNAME"));&amp;nbsp; /* Replace LIBNAME with the libname */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sort_date=input(substr(name,12,8),yymmdd8.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can now sort the dataset descending on sort_date and take row 1 as that will be the maximum date (you could do the same in one step in SQL with max()).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 11:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196097#M36836</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-03-06T11:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196098#M36837</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;@RW9 having a software version based on source text-files does not make much sense for datasets does it? &lt;/P&gt;&lt;P&gt;As the dataset will normally arrive on read-only location his question can makes sense. I agree with you that the datasetname date should have a real functional meaning not one as of ease of implementation. &lt;BR /&gt;Your supplied code is of course a good one. I would review the vtable usage as it can have problems when many RDBMS being active. The old way of using proc contents can be a by-pass in that case.&lt;/P&gt;&lt;P&gt;For the comment on dataset-naming conventions, there could be another approach with gdg's&amp;nbsp; &lt;A href="http://support.sas.com/documentation/cdl/en/lrcon/67885/HTML/default/viewer.htm#p0apy93gsj2bzmn1awyqfe7kklkp.htm" title="http://support.sas.com/documentation/cdl/en/lrcon/67885/HTML/default/viewer.htm#p0apy93gsj2bzmn1awyqfe7kklkp.htm"&gt;SAS(R) 9.4 Language Reference: Concepts, Fourth Edition&lt;/A&gt;&amp;nbsp; it is supporting historical versions of datasets.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 12:00:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196098#M36837</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-03-06T12:00:25Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196099#M36838</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="color: #575757; font-family: arial,helvetica,sans-serif; font-size: 13.3333px;"&gt;Hi,&lt;/P&gt;&lt;P style="color: #575757; font-family: arial,helvetica,sans-serif; font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="color: #575757; font-family: arial,helvetica,sans-serif; font-size: 13.3333px;"&gt;Yes, I would agree with you on the SVN not being the best tool for it.&amp;nbsp; However any software implementation of version control would, to my mind, be better that a manual one.&amp;nbsp; SVN can deal with binary files, instead of keeping changes between base and future copies though, it will take a copy of the whole file at each timepoint, hence space for the Apache serer can be an issue.&amp;nbsp; However I see so often manual copying of files to dated directories or files and manual updating of things that I never get suprised when things go wrong.&amp;nbsp; Let the software take care of things, human error is less likely then.&lt;/P&gt;&lt;P style="color: #575757; font-family: arial,helvetica,sans-serif; font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="color: #575757; font-family: arial,helvetica,sans-serif; font-size: 13.3333px;"&gt;Thanks for providing that link, it looks interesting.&amp;nbsp; Will have to look further into that.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 12:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196099#M36838</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-03-06T12:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196100#M36839</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok we agree on the goal to achieve. manual operations (data processing)&amp;nbsp; too much manual intervention in a change process (code release management) should be avoided.&lt;/P&gt;&lt;P&gt;The release process should be triggered and approved by hat there are manual interventions needed.&lt;/P&gt;&lt;P&gt;When the release/change is having many manual steps as being executed do not be surprised when something (more very often) is going to be wrong.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 13:59:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196100#M36839</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-03-06T13:59:36Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196101#M36840</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The following uses two things:&lt;/P&gt;&lt;P&gt;1. the colon(:) operater to read in datasets that begin with 'xyz',&lt;/P&gt;&lt;P&gt;2. the INDSNAME option of the set statement, which assigns the name of the dataset being read to a variable&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then simply use input and scan to pick off the date from the end of the data set name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LENGTH _dsn $ 70;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET libname.assist: INDSNAME=_dsn;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt = Input(Scan(_dsn,-1,'_'),MMDDYY8.);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call SymPut('lastdt', Put(dt, DATE.)); * end up with last date ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT dt DATE.;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 14:29:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196101#M36840</guid>
      <dc:creator>rcwright</dc:creator>
      <dc:date>2015-03-06T14:29:35Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196102#M36841</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One thing I forgot to mention, and why you might want to create a data set of dates, is that, you risk the 'last' data set not being the latest data set.&lt;/P&gt;&lt;P&gt;This might happen by virtue of the the collating sequeence of 'yyyymmdd' not being in sync with the date. So you could create the data set as above, then sort it, and then pick off the last date:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;PROC SORT DATA=x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; by dt;&lt;/P&gt;&lt;P&gt;DATA _NULL_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET x;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; call symput () ... as above&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this makes sense.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 14:35:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196102#M36841</guid>
      <dc:creator>rcwright</dc:creator>
      <dc:date>2015-03-06T14:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196103#M36842</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;PRE __jive_macro_name="quote" class="jive_text_macro jive_macro_quote"&gt;
&lt;P&gt;rcwright wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The following uses two things:&lt;/P&gt;
&lt;P&gt;1. the colon(:) operater to read in datasets that begin with 'xyz',&lt;/P&gt;
&lt;P&gt;2. the INDSNAME option of the set statement, which assigns the name of the dataset being read to a variable&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Then simply use input and scan to pick off the date from the end of the data set name&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;DATA x;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LENGTH _dsn $ 70;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET libname.assist: INDSNAME=_dsn;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dt = Input(Scan(_dsn,-1,'_'),MMDDYY8.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Call SymPut('lastdt', Put(dt, DATE.)); * end up with last date ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; FORMAT dt DATE.;&lt;/P&gt;
&lt;P&gt;RUN;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Oh my!&amp;nbsp; You will read every obs from every data set just to get one value that is actually stored in the data set name.&amp;nbsp; That seems rather inefficient to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Plus can you guarantee that the data set with the last(largest) date will be last in the "NAME RANGE".&amp;nbsp; Likely would but if the character date part actually has the data as MMDDYY I would think no.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 14:43:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196103#M36842</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-06T14:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196104#M36843</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I originally noted you can modify the above by using dataset OBS=0 (SET libname.assist:(OBS=0)) and then deleted it not wanting to get too wordy.Guess I should have included it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Not sure what you're asking about the name range - I think that was what I was trying to address in the followup - I think here you've changed the format of the data set name from what appears to be YYMMDD to MMDDYY - I was trying to follow what was given.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And there'd be nothing preventing you from manually putting in the 'last' if you have that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;There are other approaches - You could use a sashelp.vtable, sashelp.vcolumn, sashelp.vmember, and etc approach as well. I just chose this because it illustrated a couple of things not normally seen&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 15:02:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196104#M36843</guid>
      <dc:creator>rcwright</dc:creator>
      <dc:date>2015-03-06T15:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196105#M36844</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes you should have included the OBS bit and tested it too.&amp;nbsp; OBS=0 doesn't work because INDSNAME is not populated until an observation is read.&amp;nbsp; OBS=1 does.&amp;nbsp; This might have efficiently better than DICTIONARY access for some situations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; a_20150101 a_20150204 a_20150903;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; sashelp.class;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; dates;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; a:(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;obs&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt; &lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;drop&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=_all_) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;indsname&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;=indsname;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;put&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; indsname=;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;length&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; name $&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;32&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; date &lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;8&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; name = scan(indsname,-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'.'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; date = input(scan(name,-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; background-color: #ffffff;"&gt;'_'&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;),&lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;yymmdd8.&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;);&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;format&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; date &lt;/SPAN&gt;&lt;SPAN style="color: #008080; background-color: #ffffff;"&gt;date9.&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 15:33:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196105#M36844</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-03-06T15:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196106#M36845</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So do you want the one with the latest date in the table name? Or the one that was last created? Or last modified?&lt;/P&gt;&lt;P&gt;I see that your example date strings are in YYYYMMDD format, which is good because then they will sort properly when treated as character strings.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; prefix_20150302 prefix_20150301 ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; x=&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;sql&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; memname &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; :last_name trimmed&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; dictionary.tables&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; libname=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'WORK'&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; memname like &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'PREFIX%'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; memname &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;desc&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;=last_name ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; memname &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; :last_cr trimmed&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; dictionary.tables&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; libname=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'WORK'&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; memname like &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'PREFIX%'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; crdate &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;desc&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;=last_cr ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; memname &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; :last_mo trimmed&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; dictionary.tables&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; libname=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'WORK'&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; memname like &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: purple; background: white;"&gt;'PREFIX%'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; modate &lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;desc&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: .0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; &amp;amp;=last_mo ; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2015 00:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196106#M36845</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-03-07T00:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196107#M36846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi tom, why using the dictionary.tables view as it can be done with the idea of rcwrihgt (data_null- code)?&lt;/P&gt;&lt;P&gt;The difference is: the dictionary.tabels will open and check ALL&amp;nbsp; tables in All active libraries in your session (how many?) and the list access only those tables really being there.&lt;/P&gt;&lt;P&gt;Although I guess the list access will do a library check (dictionary). You could see that happen when sastrace is on with an external RDBMS.&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2015 07:42:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196107#M36846</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-03-07T07:42:53Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196108#M36847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Mainly because the request was for information about the metadata and not about the data.&amp;nbsp; The request was for the name of the dataset.&amp;nbsp; Note that tricks using INDSNAME will not work for datasets with zero observations.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dictionary tables SHOULD be smart enough to not open files for libraries that cannot match the where clause.&amp;nbsp; That is one reason why it is important to use PROC SQL and the DICTIONARY.xxx tables directly rather than useing the views in SASHELP.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2015 19:32:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196108#M36847</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-03-07T19:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196109#M36848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Tom the bad performance behavior of dictionary.tables is documented. SAS os knowing that. It is even worse when having mane pre-assigned RDBMS tables.&lt;BR /&gt; Yep it is part of the SQL implementation. &lt;A href="http://support.sas.com/documentation/cdl/en/sqlproc/65065/HTML/default/viewer.htm#n02s19q65mw08gn140bwfdh7spx7.htm" title="http://support.sas.com/documentation/cdl/en/sqlproc/65065/HTML/default/viewer.htm#n02s19q65mw08gn140bwfdh7spx7.htm"&gt;SAS(R) 9.4 SQL Procedure User's Guide&lt;/A&gt;&amp;nbsp; The notes are:&lt;/P&gt;&lt;P class="xis-note"&gt;&lt;A id="p15vc8zbuvsbbfn1sh7gf2j3h44y"&gt;&lt;/A&gt;&lt;SPAN class="xis-noteGenText"&gt;Note: &lt;/SPAN&gt;SAS does not maintain DICTIONARY table information between queries. Each query of a DICTIONARY table launches a new discovery process. &lt;/P&gt;&lt;P class="xis-paragraph"&gt;&lt;A id="n1syz77jvidgu1n1keqbbu4mjo65"&gt;&lt;/A&gt;&amp;nbsp; When you query DICTIONARY.Tables or Sashelp.Vtable, all of the tables and views in all libraries that are assigned to the SAS session are opened to retrieve the requested information. &lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;A id="n0xcin54p3mvshn1g0y9kgofz25x"&gt;&lt;/A&gt;You can use a WHERE clause to help restrict which libraries are searched. However, the WHERE clause does not process most function calls such as UPCASE. &lt;/P&gt;&lt;P class="xis-note"&gt;&lt;A id="p0uxxjjvkaiyedn1w7n5umvaxvkw"&gt;&lt;/A&gt;&lt;SPAN class="xis-noteGenText"&gt;Note: &lt;/SPAN&gt;Searching all librefs might cause unexpected results. If all librefs are searched, a view might exist that contains a libref that is not currently assigned to the SAS session. When this view is opened to retrieve information for the query, an error occurs. &lt;/P&gt;&lt;P class="xis-note"&gt;&lt;SPAN class="xis-noteGenText"&gt;Note: &lt;/SPAN&gt;If you query table information from a library that is assigned to an external database, and you use the LIBNAME statement PRESERVE_TAB_NAMES=YES option or the PRESERVE_COL_NAMES=YES option, and you &lt;BR /&gt;provide the table or column name as it appears in the database, you do not need&amp;nbsp; to use the UPCASE function. &lt;/P&gt;&lt;P class="xis-note"&gt;&lt;/P&gt;&lt;P class="xis-note"&gt;The problem of retrieving all kind of dictionary info before some action is done is known, see: &lt;A href="http://blogs.sas.com/content/sasdummy/2013/07/08/proc-delete-its-not-dead-yet/" title="http://blogs.sas.com/content/sasdummy/2013/07/08/proc-delete-its-not-dead-yet/"&gt;http://blogs.sas.com/content/sasdummy/2013/07/08/proc-delete-its-not-dead-yet/&lt;/A&gt; &lt;/P&gt;&lt;P class="xis-note"&gt;&lt;/P&gt;&lt;P class="xis-note"&gt;Real life experience:&lt;/P&gt;&lt;P class="xis-note"&gt;Now do some quality checks on code being delivered by very expensive consultants or analysts as they are complaining performance with SAS is very bad *unhappy users".&lt;/P&gt;&lt;P class="xis-note"&gt;Seeing the discovery done several times in one job-flow and discovery being done on not used external tables a response time for some simple SAS steps of 30 minutes.&amp;nbsp; All those external RDBMS connections with al lot of tables were being new.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2015 21:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196109#M36848</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-03-07T21:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196110#M36849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The problems you note are real and suggest that using DICTIONARY tables should be done with care.&amp;nbsp; For this problem the only possible issue would be if the library the user wanted to search had many tables defined.&amp;nbsp; The other problems noted do not apply since the use of&amp;nbsp; &lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: blue; background-color: white;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt; libname=&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: purple; background-color: white;"&gt;'WORK'&lt;/SPAN&gt;&lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt; &lt;/SPAN&gt; in the query will prevent SAS from trying to access other libraries.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2015 21:25:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196110#M36849</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-03-07T21:25:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196111#M36850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agree on that one with 9.4 and using proc Sql it should be optimized to not access all other libraries. When there is response time problem (extensively researched that one as needing to have total turn=around times below 10 sec)&amp;nbsp; Seen all those issues with that. AS you cannot trace the discovery process the only measurement is the turn-around time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This topic is coming at most too late, after image for SAS damage has happened.&lt;/P&gt;&lt;P&gt;How many SAS guys/girls are aware on those quirks behind the curtains of dictionary.tables (members).&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 07 Mar 2015 21:34:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196111#M36850</guid>
      <dc:creator>jakarman</dc:creator>
      <dc:date>2015-03-07T21:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196112#M36851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;Apologies for not being able to get involved in the discussion, was busy in some emegency.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;@tom: You got it right, I just want to have a macro variable which should return the &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;YYYYMMDD&lt;/STRONG&gt;&lt;/SPAN&gt; part of the dataset name based on the &lt;SPAN style="text-decoration: underline;"&gt;&lt;STRONG&gt;latest date in the table name&lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 01:16:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196112#M36851</guid>
      <dc:creator>KP12</dc:creator>
      <dc:date>2015-03-09T01:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196113#M36852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This query will look for the last name that starts with ASSISTANCE_ in the library specified by the macro variable LIBREF.&lt;/P&gt;&lt;P&gt;If your library is not clutter with other datasets whose name start with 'ASSISTANCE_' then it should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: navy;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;%let libref=libname;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: navy;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;%let lastdt=none;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: navy;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;proc&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: navy;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;sql&lt;/STRONG&gt;&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;noprint&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;select&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; scan(memname,-1,'_') &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;into&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; :lastdt trimmed&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;from&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; dictionary.tables&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; libname=%upcase("&amp;amp;libref")&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;and&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; memname like &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: purple;"&gt;'ASSISTANCE^_%' ESCAPE '^'&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;order&lt;/SPAN&gt; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt; memname &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: blue;"&gt;desc&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-size: 10pt; font-family: 'Courier New'; color: black;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: navy; background-color: white;"&gt;&lt;STRONG style="font-style: inherit; font-family: inherit;"&gt;quit&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; font-family: 'Courier New'; color: black; background-color: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 02:46:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196113#M36852</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-03-09T02:46:32Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196114#M36853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi RW9,&lt;/P&gt;&lt;P&gt;Thank you very much for your response &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt; . As the company is following this nomenclature for the dataset names, so | can't make the changes on my own &lt;img id="smileysad" class="emoticon emoticon-smileysad" src="https://communities.sas.com/i/smilies/16x16_smiley-sad.png" alt="Smiley Sad" title="Smiley Sad" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 02:51:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196114#M36853</guid>
      <dc:creator>KP12</dc:creator>
      <dc:date>2015-03-09T02:51:15Z</dc:date>
    </item>
    <item>
      <title>Re: Assign macro variable value by extracting date from dataset name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196115#M36854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;dictionary.members would be faster.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;
data a_20150101 a_20150204 a_20150903;
&amp;nbsp;&amp;nbsp; set sashelp.class;
&amp;nbsp;&amp;nbsp; run; 

proc sql;
 select input(strip(scan(memname,-1,'_')),anydtdte.) as d format=yymmddn. into : d
&amp;nbsp; from dictionary.members
&amp;nbsp;&amp;nbsp; having libname='WORK' and calculated d=max(calculated d);
quit;
%put &amp;amp;d&amp;nbsp; ;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Xia Keshan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Mar 2015 05:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Assign-macro-variable-value-by-extracting-date-from-dataset-name/m-p/196115#M36854</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2015-03-09T05:27:52Z</dc:date>
    </item>
  </channel>
</rss>

