<?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: I want to find the latest file and wanted to move it in a different folder. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639693#M190359</link>
    <description>hi, I used DICTIONARY.TABLES but it did'nt work for me, I just wanted to move the latest file in to the folder, how can I, can MACROS makes my life easier?</description>
    <pubDate>Tue, 14 Apr 2020 11:28:03 GMT</pubDate>
    <dc:creator>annypanny</dc:creator>
    <dc:date>2020-04-14T11:28:03Z</dc:date>
    <item>
      <title>How to find the latest file and how to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639687#M190354</link>
      <description>&lt;P&gt;Hi, suppose I have multiple external files e,g.onlineuser20200414.txt , onlineuser20200415.txt, Userxyz.txt in a input folder location&amp;nbsp; "/loc/sasdataset/lev1" &amp;nbsp;now the latest file i.e., onlineuser20200415.txt from that location I have to extract into a dataset and will be moved to different archived folder location "/loc/sasdataset/xyz" and if any file aged more than 30 days e.g onlineuser20200314.txt will be automatically deleted from the location "/loc/sasdataset/xyz". How can I find the latest file and extract it into a dataset in sas EG? Please if anybody give a code example.&lt;/P&gt;
&lt;P&gt;Thanks in advance&lt;/P&gt;
&lt;P&gt;Edited&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:00:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639687#M190354</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T07:00:42Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639692#M190358</link>
      <description>&lt;P&gt;In SQL, query DICTIONARY.TABLES to find the latest. Note that if you always MOVE files, you will (in the long run) only find one dataset (the most recently added) anyway.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 11:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639692#M190358</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-14T11:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639693#M190359</link>
      <description>hi, I used DICTIONARY.TABLES but it did'nt work for me, I just wanted to move the latest file in to the folder, how can I, can MACROS makes my life easier?</description>
      <pubDate>Tue, 14 Apr 2020 11:28:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639693#M190359</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-14T11:28:03Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639696#M190362</link>
      <description>&lt;P&gt;How did you query DICTIONARY.TABLES? Please post your code, using the "little running man" button.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 11:33:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639696#M190362</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-14T11:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639697#M190363</link>
      <description>&lt;P&gt;Are these SAS tables or some external files on disk?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 11:35:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639697#M190363</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2020-04-14T11:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639698#M190364</link>
      <description>sas tables&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Apr 2020 11:36:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639698#M190364</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-14T11:36:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to find the latest file and how to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639750#M190385</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Where the files in*/
%let repfic=H:\;

/*Where to move*/
%let repmove=H:\Batch;

/*ficrep contains all files name in the &amp;amp;refic*/
FILENAME ficrep PIPE "dir /b &amp;amp;repfic";

/*create table SAS = ficrep, it is necessary if in ficrep have the other file*/
data toto;
infile ficrep end=eof;
length x $50;
input x;
run;


/*traitement*/
data tata;  /*data _null_;*/
set toto(where=(x like "online%"));
length _repname _repmove $200;

_y=put(date(),yymmddN.); /*date today 20200414*/
_over30=put(date()-30,yymmddN.); /*date aged 30day 20200315*/
_datex=substr(x,11,8);			/*date in filename*/
_repname=cats("&amp;amp;repfic",x);		/*H:\onlineuseryyyymmdd.txt*/
_repmove=catx(" ",x,"&amp;amp;repmove");	/* onlineuseryyyymmdd.txt H:\batch*/

if _datex le _over30 then do;
delete=1;						/*if file aged over 30 days */
Call system(catx(" ","del /Q",_repname));	/*execute a command line windows del /q H:\onlineuseryyyymmdd.txt */
end;										/*    = suppress the file*/
if _datex = _y then do;
move=1;
call system(cats("move /Y &amp;amp;repfic\",_repmove));	/*move /y h:\onlineuseryyyymmdd.txt H:\batch*/
end;												/* move the file to the path spécified*/
drop _:;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I'm not sure thit is what you want but i hope this can help you.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 13:39:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639750#M190385</guid>
      <dc:creator>kelxxx</dc:creator>
      <dc:date>2020-04-14T13:39:06Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639752#M190387</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/316738"&gt;@annypanny&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;sas tables&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why did your original post use .txt extension on the file names if they are SAS datasets?&amp;nbsp; SAS datasets use .sas7bat as the extension.&amp;nbsp; DICTIONARY.TABLES will not show text files.&amp;nbsp; Just datasets (and then only for places pointed to by active librefs).&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 13:43:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639752#M190387</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-14T13:43:46Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639766#M190389</link>
      <description>&lt;P&gt;It did not have the .txt, that's why I suggested using the dictionary tables. But we seem to have a goalpost-mover here.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To the OP: please add a line declaring the edit if you have to edit one of your posts (except if it's just correcting a typo).&lt;/P&gt;
&lt;P&gt;If I had known that you were talking about &lt;STRONG&gt;external text files&lt;/STRONG&gt;, I would not have suggested the dictionary tables at all.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2020 14:06:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639766#M190389</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-14T14:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639964#M190461</link>
      <description>sorry for that, it was confusing&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Apr 2020 04:58:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639964#M190461</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T04:58:37Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639973#M190468</link>
      <description>&lt;P&gt;So what are we really talking about, datasets or external files?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 05:53:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639973#M190468</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-15T05:53:16Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639978#M190473</link>
      <description>datasets</description>
      <pubDate>Wed, 15 Apr 2020 06:13:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639978#M190473</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T06:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639980#M190475</link>
      <description>&lt;P&gt;Then dictionary.tables is the way to go. Show the SQL code that you tried, post the log from it using the &amp;lt;/&amp;gt; button.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 06:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639980#M190475</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-15T06:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639983#M190478</link>
      <description>&lt;P&gt;&amp;lt;/filename file "/sas/sasdataset/lev1/";&lt;/P&gt;&lt;P&gt;data latest;&lt;/P&gt;&lt;P&gt;set file.latest;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;TABLE border="1" cellspacing="0" cellpadding="6"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;CODE&gt;&lt;STRONG&gt;create view file as select * from dictionary.tables;&lt;/STRONG&gt;&lt;/CODE&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;/&amp;gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 06:26:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639983#M190478</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T06:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639988#M190483</link>
      <description>&lt;P&gt;To find &lt;U&gt;SAS datasets&lt;/U&gt;, define a libname for the directory, then use DICTIONARY.TABLES:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname file "/sas/sasdataset/lev1/";

proc sql;
create table datasets_in_file as
  select *
  from dictionary.tables
  where libname = 'FILE' /* always use uppercase for libnames and memnames */
;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2020 06:50:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639988#M190483</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-15T06:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639991#M190486</link>
      <description>and what if it is a extrnal file not sas dataset? just asking for curiosity then we can't use libname then how can I do that?</description>
      <pubDate>Wed, 15 Apr 2020 06:57:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639991#M190486</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T06:57:06Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639994#M190489</link>
      <description>&lt;P&gt;See my answer in your other thread.&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/316738"&gt;@annypanny&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;and what if it is a extrnal file not sas dataset? just asking for curiosity then we can't use libname then how can I do that?&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:03:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/639994#M190489</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-15T07:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/640000#M190495</link>
      <description>sure, how can I move a dataset in to different location?&lt;BR /&gt;By using X command?&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:08:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/640000#M190495</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T07:08:19Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/640002#M190497</link>
      <description>&lt;P&gt;SAS provides a function for copying files:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/?cdcId=pgmsascdc&amp;amp;cdcVersion=9.4_3.4&amp;amp;docsetId=lefunctionsref&amp;amp;docsetTarget=n10dz22b5ixohin1vwzilweetek0.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;FCOPY Function&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 07:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/640002#M190497</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-15T07:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: I want to find the latest file and wanted to move it in a different folder.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/640010#M190502</link>
      <description>And how can I delete a file if it's age is more than 30 days?</description>
      <pubDate>Wed, 15 Apr 2020 07:27:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-find-the-latest-file-and-how-to-move-it-in-a-different/m-p/640010#M190502</guid>
      <dc:creator>annypanny</dc:creator>
      <dc:date>2020-04-15T07:27:20Z</dc:date>
    </item>
  </channel>
</rss>

