<?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: Reading and compiling daily txt file with different dates in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637988#M21518</link>
    <description>&lt;P&gt;To read all files at once and remember which file each row came from, use a wildcard:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length fromFile $400;
infile "/share/gsas_vnx_frl/Users/Carlos_Jimenez/Automation/PCS _ADDRESS_CHANGE/Daily/PCALB110_*.txt"
FILENAME=FN .... ;
fromFile = FN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 07 Apr 2020 03:40:01 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2020-04-07T03:40:01Z</dc:date>
    <item>
      <title>Reading and compiling daily txt file with different dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637961#M21505</link>
      <description>&lt;P&gt;I am have over 300 txt files to read; the only difference in the file name is the prefix date value. They range from 20190924 to 202000403.&amp;nbsp; I am having a hard time with a macro and loop to read and append all 300 files.&amp;nbsp; Below is are examples:&lt;/P&gt;&lt;P&gt;PCALB110_20190924.txt&lt;/P&gt;&lt;P&gt;PCALB110_20190925.txt&lt;/P&gt;&lt;P&gt;PCALB110_20190926.txt&lt;/P&gt;&lt;P&gt;....&lt;/P&gt;&lt;P&gt;PCALB110_20200403.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was trying to do something like;&lt;/P&gt;&lt;P&gt;%macro STACK;&lt;/P&gt;&lt;P&gt;%DO I='23sep2019'd %TO '26sep2019'd;&lt;BR /&gt;data a;&lt;BR /&gt;infile "/share/gsas_vnx_frl/Users/Carlos_Jimenez/Automation/PCS _ADDRESS_CHANGE/Daily/PCALB110_%sysfunc(compress(put(&amp;amp;I.,yymmdd10.),"-")).txt" LRECL=335&lt;BR /&gt;ENCODING="LATIN1"&lt;BR /&gt;TERMSTR=CRLF&lt;BR /&gt;DLM='7F'x&lt;BR /&gt;MISSOVER&lt;BR /&gt;DSD ;&lt;BR /&gt;input&lt;BR /&gt;NAME_BEFORE_CHANGE $ 1-40&lt;BR /&gt;NAME_AFTER_CHANGE $ 41-80&lt;BR /&gt;CARD_NUMBER $ 81-96&lt;BR /&gt;ACCOUNT_TYPE $ 97-99&lt;BR /&gt;ACCOUNT_NUMBER $100-109&lt;BR /&gt;OLD_ADDRESS $ 110-149&lt;BR /&gt;OLD_CITY_STATE_ZIP $ 150-189&lt;BR /&gt;NEW_ADDRESS $ 190-229&lt;BR /&gt;NEW_CITY_STATE_ZIP $ 230-269&lt;BR /&gt;ADDRESS_CHANGE_DATE $ 270-277&lt;BR /&gt;OPERATOR_ID $ 278-285&lt;BR /&gt;OPERATOR_NAME $ 286-325&lt;BR /&gt;;&lt;BR /&gt;DATE="&amp;amp;I"; format date mmddyy10.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc append data=a out=stack force;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;%END;&lt;BR /&gt;%MEND;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, it didn't work.&amp;nbsp; Ideas??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Apr 2020 23:46:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637961#M21505</guid>
      <dc:creator>carlos_jimenez</dc:creator>
      <dc:date>2020-04-06T23:46:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reading and compiling daily txt file with different dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637975#M21510</link>
      <description>&lt;P data-unlink="true"&gt;Hi,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/51136"&gt;@carlos_jimenez&lt;/a&gt;! Thanks for posting your query through our SAS Communities. For your specific issue, you may refer to &lt;A href="https://communities.sas.com/t5/General-SAS-Programming/Append-All-TXT-Files-in-a-Folder-to-a-Dataset/td-p/434305" target="_self"&gt;this link&lt;/A&gt;&amp;nbsp; which discussed similar scenario like yours. Hope this helps.&lt;WBR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 01:35:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637975#M21510</guid>
      <dc:creator>SAS_Cares</dc:creator>
      <dc:date>2020-04-07T01:35:05Z</dc:date>
    </item>
    <item>
      <title>Re: Reading and compiling daily txt file with different dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637979#M21512</link>
      <description>&lt;P&gt;Here are a couple of ideas why your code might not work.&lt;/P&gt;
&lt;P&gt;1) The normal %EVAL() macro function that SAS uses in %IF and %DO statements does not recognize date literals. You can use %SYSEVALF() and it will recognize the date literals.&lt;/P&gt;
&lt;P&gt;2) You are defining DATE as a string and then trying to attach the numeric format MMDDYY to it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%DO I=%sysevalf('23sep2019'd) %TO %sysevalf('26sep2019'd);
...
date=&amp;amp;i;
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;3) When you use %SYSFUNC() to call regular SAS functions in macro code you need to wrap each function in separated %SYSFUNC() function call.&amp;nbsp; Also there is no need to remove quotes from the output of the PUT, it does not generate any quotes.&amp;nbsp; Put why not also not generate the hyphens either?&amp;nbsp; Then there is no need for the COMPRESS() function.&amp;nbsp; Also you cannot use PUT() with %SYSFUNC() since it cannot figure out if your format is numeric or character.&amp;nbsp; Use PUTN() since you are formatting a numeric value using a numeric format.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%sysfunc(putn(&amp;amp;I.,yymmddN10.))&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;4) I think you need to use BASE= not OUT= in PROC APPEND (unless it sees OUT= as an alias for BASE=).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course it would be easier to just read all of the files in a single data step.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or is it important that you only read the files whose names fall into that date range?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Apr 2020 01:54:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637979#M21512</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-04-07T01:54:33Z</dc:date>
    </item>
    <item>
      <title>Re: Reading and compiling daily txt file with different dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637988#M21518</link>
      <description>&lt;P&gt;To read all files at once and remember which file each row came from, use a wildcard:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;length fromFile $400;
infile "/share/gsas_vnx_frl/Users/Carlos_Jimenez/Automation/PCS _ADDRESS_CHANGE/Daily/PCALB110_*.txt"
FILENAME=FN .... ;
fromFile = FN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Apr 2020 03:40:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637988#M21518</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-04-07T03:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Reading and compiling daily txt file with different dates</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637994#M21521</link>
      <description>&lt;P&gt;Once you have made your %do loop working (see the other suggestions), simplify your INFILE statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;infile "/share/gsas_vnx_frl/Users/Carlos_Jimenez/Automation/PCS _ADDRESS_CHANGE/Daily/PCALB110_%sysfunc(putn(&amp;amp;I.,yymmddn8.)).txt" LRECL=335;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 07 Apr 2020 07:02:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reading-and-compiling-daily-txt-file-with-different-dates/m-p/637994#M21521</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-04-07T07:02:18Z</dc:date>
    </item>
  </channel>
</rss>

