<?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: Libname assigned to partial file name? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843210#M333375</link>
    <description>&lt;P&gt;I'm not sure I know what you want.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Can you show us the actual way things are now and clearly point out the problem, and how you envision things would be if you fixed it? Please use the Insert Photos icon to include screen captures in your reply. Do not attach files.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Nov 2022 18:33:46 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-11-08T18:33:46Z</dc:date>
    <item>
      <title>Libname assigned to partial file name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843207#M333373</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I have a data directory/folder that is updated monthly with the same naming convention each month. The only thing that changes in the directory name and path is the date at the end of the directory name. Unfortunately, that date is not consistent and changes month to month (e.g. not always on the 2nd day of the month, etc., so I can't use a date macro). Is it possible to assign a libname to a partial directory name (e.g. just to "C:\monthlydata\CCMonthlyRun")? That way I wouldn't have to update the date every time I need to reference that library?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Example of current lib statement:&lt;/P&gt;&lt;P&gt;libname TestX "C:\monthlydata\CCMonthlyRun[11.04.22]";&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 22:56:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843207#M333373</guid>
      <dc:creator>bananah13</dc:creator>
      <dc:date>2022-11-08T22:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: Libname assigned to partial file name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843210#M333375</link>
      <description>&lt;P&gt;I'm not sure I know what you want.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Can you show us the actual way things are now and clearly point out the problem, and how you envision things would be if you fixed it? Please use the Insert Photos icon to include screen captures in your reply. Do not attach files.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 18:33:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843210#M333375</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-11-08T18:33:46Z</dc:date>
    </item>
    <item>
      <title>Re: Libname assigned to partial file name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843215#M333376</link>
      <description>You can scan the folder for filenames and find the most recent file updated. Search on here to find that question answered almost every month. &lt;BR /&gt;&lt;BR /&gt;If your file naming convention has the day part only changing you could also wildcard that part of the name only.  &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 08 Nov 2022 18:46:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843215#M333376</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2022-11-08T18:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Libname assigned to partial file name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843216#M333377</link>
      <description>&lt;P&gt;I assume that you mean that the name of the DIRECTORY that houses the file changes (and not the name of the file which is just based on the name of the dataset).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is easy to get a list of files and directories in a file.&amp;nbsp; The simplest is if you can just ask the operating system to tell you.&amp;nbsp; Since it looks like you are using Windows let's use the DIR command.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data files;
  infile "dir ""C:\monthlydata\"" /b" pipe;
  input filename $256. ;
  if filename=:'CCMonthlyRun';
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you cannot use the PIPE engine then check out the DOPEN() and DREAD() functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have the list then parse out the date part of the name and convert it into an actual DATE value.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dates;
  set files;
  date = input(substr(filename,length('CCMonthlyRun')+1),anyddte.);
  format date yymmdd10.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then you can apply some logic to decide which of the names you want to use.&amp;nbsp; Perhaps the latest one?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=dates;
  by date;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And once you have picked one then you can assign that value to a macro variable.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  set dates end=eof;
  if eof then call symputx('dirname',filename);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which you can use in your code.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname textx "C:\monthlydata\&amp;amp;dirname";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 18:54:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843216#M333377</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-11-08T18:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Libname assigned to partial file name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843219#M333378</link>
      <description>&lt;P&gt;You may want to consider the implications of changing from a folder per month approach to storing your SAS data, to just having one folder where the dataset name suffix identifies the month of the data (MyDataset_20220411). Then your LIBNAME problem disappears and SAS library maintenance becomes much more efficient.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 19:02:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843219#M333378</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-11-08T19:02:57Z</dc:date>
    </item>
    <item>
      <title>Re: Libname assigned to partial file name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843256#M333384</link>
      <description>&lt;P&gt;Thank you, this worked like a charm!&lt;/P&gt;</description>
      <pubDate>Tue, 08 Nov 2022 22:49:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843256#M333384</guid>
      <dc:creator>bananah13</dc:creator>
      <dc:date>2022-11-08T22:49:39Z</dc:date>
    </item>
    <item>
      <title>Re: Libname assigned to partial file name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843290#M333396</link>
      <description>&lt;P&gt;On top of what everyone else said, never use 2-digit years (this should be a total given after Y2K!), and use dates in YMD notation, so the filenames sort correctly on their own.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Nov 2022 07:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Libname-assigned-to-partial-file-name/m-p/843290#M333396</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-11-09T07:28:15Z</dc:date>
    </item>
  </channel>
</rss>

