<?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: How to automatically update a file from a directory? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/805016#M317078</link>
    <description>Hi Ballardw:&lt;BR /&gt;Thanks so much for clarification. for the csv file, what I need is to read the latest upload file (since the old version will be moved to Archive), currently we don't need to combine data, but knowing this tip is very important.</description>
    <pubDate>Wed, 30 Mar 2022 12:13:12 GMT</pubDate>
    <dc:creator>purpleclothlady</dc:creator>
    <dc:date>2022-03-30T12:13:12Z</dc:date>
    <item>
      <title>How to automatically update a file from a directory?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804862#M316980</link>
      <description>&lt;P&gt;Hi All:&lt;/P&gt;
&lt;P&gt;How to automatically update a fil from a directory?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;eg.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;HAVE &lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;libname a_location&amp;nbsp; 'C:\user'; &lt;BR /&gt;filename abc&amp;nbsp; "C:\Tests\&lt;FONT color="#FFFF00"&gt;&lt;FONT color="#0000FF"&gt;test&lt;EM&gt;&lt;STRONG&gt;20220303.csv&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;"&lt;/FONT&gt;&lt;BR /&gt;lrecl=10000;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;(&lt;STRONG&gt;AFTER A FEW WEEKS )WANT:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;libname a_location&amp;nbsp; 'C:\user'; &lt;BR /&gt;filename abc&amp;nbsp; "C:\Tests\&lt;FONT color="#993300"&gt;test&lt;EM&gt;&lt;STRONG&gt;20220329.csv&lt;/STRONG&gt;&lt;/EM&gt;&lt;/FONT&gt;"&lt;BR /&gt;lrecl=10000;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc import datafile=ABC&lt;BR /&gt;dbms=csv &lt;BR /&gt;out=ABC_WANT&lt;BR /&gt;replace; &lt;BR /&gt;delimiter=',';&lt;BR /&gt;getnames=yes;&lt;BR /&gt;guessingrows=max;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for helping,&lt;/P&gt;
&lt;P&gt;purple&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 18:42:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804862#M316980</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2022-03-29T18:42:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically update a file from a directory?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804867#M316982</link>
      <description>&lt;P&gt;Can you explain how the programmer will know what file name is to be used?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I could guess, but sometimes (well almost always) its better for the original poster to state clearly the criteria to be used.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 19:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804867#M316982</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-29T19:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically update a file from a directory?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804871#M316985</link>
      <description>&lt;P&gt;Unless your data source is extremely careful relying on proc import to read files creates character values of different lengths and sometimes variables that are character in one data set and numeric in another. Which means you will have issues when combining data sets and likely in other places.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Write a data step, or modify one generated by Proc Import (copy the code from the log, paste into the editor and clean up, set properties of variables as the documentation from the file source should provide).&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 19:12:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804871#M316985</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-29T19:12:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically update a file from a directory?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804874#M316987</link>
      <description>hi Paige:&lt;BR /&gt;the file name is csv file. every now and then , we have to import the updated CSV file (for example: from "test20220303.csv" to "test20220329.csv" , but I have to check manually by going to the directory (there has not a set date so I have to check manually every time when I need update the CSV file)&lt;BR /&gt;thanks&lt;BR /&gt;purple</description>
      <pubDate>Tue, 29 Mar 2022 19:21:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804874#M316987</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2022-03-29T19:21:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically update a file from a directory?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804875#M316988</link>
      <description>&lt;P&gt;You can have SAS read the list of files in a folder/directory, and then have SAS determine which one to read. The method to read file names from a folder has been discussed regularly in the SAS Communities, here is one solution: &lt;A href="https://communities.sas.com/t5/SAS-Programming/Read-in-CSV-from-folder-with-newest-date/m-p/709267#M218069" target="_blank"&gt;https://communities.sas.com/t5/SAS-Programming/Read-in-CSV-from-folder-with-newest-date/m-p/709267#M218069&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Mar 2022 19:33:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/804875#M316988</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-03-29T19:33:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically update a file from a directory?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/805016#M317078</link>
      <description>Hi Ballardw:&lt;BR /&gt;Thanks so much for clarification. for the csv file, what I need is to read the latest upload file (since the old version will be moved to Archive), currently we don't need to combine data, but knowing this tip is very important.</description>
      <pubDate>Wed, 30 Mar 2022 12:13:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/805016#M317078</guid>
      <dc:creator>purpleclothlady</dc:creator>
      <dc:date>2022-03-30T12:13:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically update a file from a directory?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/805075#M317085</link>
      <description>&lt;P&gt;Once you have the list of files as a dataset then just use normal SAS coding to figure out which one is the latest one.&amp;nbsp; From your description you might want to extract the date from the text of the filename itself.&amp;nbsp; But you might also want to check the last modified timestamp you got from the operating system when generating the list of filenames.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have picked the filename you want you can just put the name into a macro variable and use that in your code.&amp;nbsp; For example by using CALL SYMPUTX() function in a data step to create the macro variable.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 13:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/805075#M317085</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-03-30T13:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to automatically update a file from a directory?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/805077#M317087</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/347922"&gt;@purpleclothlady&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi Ballardw:&lt;BR /&gt;Thanks so much for clarification. for the csv file, what I need is to read the latest upload file (since the old version will be moved to Archive), currently we don't need to combine data, but knowing this tip is very important.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Since you say the "old version will be moved" there could be a critical question: Are there any other files in the source folder that have the same name minus the date part? If there is only going to be &lt;STRONG&gt;one&lt;/STRONG&gt; file named Testyyyymmdd.csv in that folder you can reference the file name with a with a wildcard: "C:\folder\filename*.csv" for example. That would then refer to the only file that starts with Filename and is a CSV file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Still say you would be better off writing a data step, then you place that wildcard on the INFILE statement and the program doesn't have to be updated at all - as long as that is the only file matching that naming convention.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I use a similar wild card to read a folder that has an increasing number of files of the same name/structure to read all of them into a single file. That project receives corrected versions of the raw data occasionally so I replace the old file with the corrected data and rerun the read program to bring the corrected data into the data set.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 14:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-automatically-update-a-file-from-a-directory/m-p/805077#M317087</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-30T14:24:22Z</dc:date>
    </item>
  </channel>
</rss>

