<?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 import csv file and append to SAS data set with changing pattern in file name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606322#M176053</link>
    <description>Yes, i want to import them all as well as the new files that i get everyday either way</description>
    <pubDate>Thu, 21 Nov 2019 22:33:19 GMT</pubDate>
    <dc:creator>rsingh92</dc:creator>
    <dc:date>2019-11-21T22:33:19Z</dc:date>
    <item>
      <title>I want to import csv file and append to SAS data set with changing pattern in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606313#M176050</link>
      <description>&lt;P&gt;Hi Folks -&amp;nbsp; I am new to SAS macros.&lt;/P&gt;&lt;P&gt;My task is to import csv file to SAS data set.&amp;nbsp; I get new file every morning for example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp;Category_-_Yesterday-11-01-19-0907.csv&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;Category_-_Yesterday-11-02-19-0904.csv&lt;/P&gt;&lt;P&gt;3.&amp;nbsp;Category_-_Yesterday-11-03-19-1016.csv&lt;/P&gt;&lt;P&gt;4.&amp;nbsp;Category_-_Yesterday-11-04-19-0925.csv&lt;/P&gt;&lt;P&gt;5.&amp;nbsp;Category_-_Yesterday-11-05-19-0816.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;file pattern is like =&amp;nbsp; Category_-_Yesterday-&amp;amp;today-RandomNumbers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried braking this but it doesn't work. It is not able to read RandonNumbers&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let today=%sysfunc(today(), MMDDYYD8.);&lt;BR /&gt;%let file=Category_-_Yesterday-&amp;amp;today-;&lt;BR /&gt;%let extension= "*".csv;&lt;BR /&gt;%let file_loc=\C:\myfile\&amp;amp;statusfile.&amp;amp;extension.;&lt;BR /&gt;%put &amp;amp;today.;&lt;BR /&gt;%put &amp;amp;extension.;&lt;BR /&gt;%put &amp;amp;file.;&lt;BR /&gt;%put &amp;amp;file_loc.;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;filename DIRLIST pipe &amp;amp;file_loc ; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone please help me on how to read date and random numbers in file name and automate the import process.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help !!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;$file&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 22:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606313#M176050</guid>
      <dc:creator>rsingh92</dc:creator>
      <dc:date>2019-11-21T22:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: I want to import csv file and append to SAS data set with changing pattern in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606320#M176052</link>
      <description>&lt;P&gt;Do you want to import them all?&lt;/P&gt;
&lt;P&gt;Using a data step or proc import?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 22:28:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606320#M176052</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-11-21T22:28:35Z</dc:date>
    </item>
    <item>
      <title>Re: I want to import csv file and append to SAS data set with changing pattern in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606322#M176053</link>
      <description>Yes, i want to import them all as well as the new files that i get everyday either way</description>
      <pubDate>Thu, 21 Nov 2019 22:33:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606322#M176053</guid>
      <dc:creator>rsingh92</dc:creator>
      <dc:date>2019-11-21T22:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: I want to import csv file and append to SAS data set with changing pattern in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606325#M176054</link>
      <description>&lt;P&gt;If you use a data &lt;FONT face="arial,helvetica,sans-serif"&gt;step,&lt;/FONT&gt; try&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;%let file_name =Category_-_Yesterday-&amp;amp;today-*.csv;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;%let file_loc&amp;nbsp; =C:\myfile\&amp;amp;file_name;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;filename DIRLIST "&amp;amp;file_loc" ; &lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;if not, read this:&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="arial,helvetica,sans-serif"&gt;&lt;A href="https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0ctmldxf23ixtn1kqsoh5bsgmg8.htm&amp;amp;docsetVersion=9.4" target="_blank"&gt;https://documentation.sas.com/?docsetId=mcrolref&amp;amp;docsetTarget=n0ctmldxf23ixtn1kqsoh5bsgmg8.htm&amp;amp;docsetVersion=9.4&lt;/A&gt;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 22:34:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606325#M176054</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-11-21T22:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: I want to import csv file and append to SAS data set with changing pattern in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606328#M176056</link>
      <description>&lt;P&gt;&lt;EM&gt;&amp;gt; Yes, i want to import them all as well as the new files that i get everyday either way&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;How do you which ones to import?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Nov 2019 22:35:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606328#M176056</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-11-21T22:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: I want to import csv file and append to SAS data set with changing pattern in file name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606357#M176067</link>
      <description>&lt;P&gt;1. Use SAS to get a list of files in the folder. Check the SAS macro appendix for the code on how to do this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Check a list of files read and if read, leave it, if not read.&amp;nbsp;&lt;BR /&gt;3. read file&lt;/P&gt;
&lt;P&gt;4. If successful, add name to dataset of files read.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Alternatively, you could read all at once every time or just read the newest file. This only works if you only ever update it one file at a time though. Some other tutorials on macros are below.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;UCLA introductory tutorial on macro variables and macros&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Tutorial on converting a working program to a macro&lt;BR /&gt;&lt;BR /&gt;This method is pretty robust and helps prevent errors and makes it much easier to debug your code. Obviously biased, because I wrote it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;A href="https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md" target="_blank"&gt;https://github.com/statgeek/SAS-Tutorials/blob/master/Turning%20a%20program%20into%20a%20macro.md&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Examples of common macro usage&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/SAS-9-4-Macro-Language-Reference-Has-a-New-Appendix/ta-p/291716&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, those aren’t random numbers at the end, they’re likely the time stamps of when the file was generated to ensure each file generated is uniquely identified.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Nov 2019 02:00:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/I-want-to-import-csv-file-and-append-to-SAS-data-set-with/m-p/606357#M176067</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-11-22T02:00:29Z</dc:date>
    </item>
  </channel>
</rss>

