<?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: IMPORT 1/2/3/4/5/6/7/8/9/10 days before if file doesn't exist in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617165#M180798</link>
    <description>&lt;P&gt;We always advise you to handle dates as integers representing the number of days since 1/1/1960. That way, it becomes very easy to figure out what day is 10 days before 03MAR19, using the INTNX function, or even simpler by plain subtraction of 10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to go back and re-formulate your solution to do the calculations using actual SAS date values and subtraction. Use formatting to turn the result into something like&amp;nbsp;1901025.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, what does that 7 digit string 1901025 represent anyway?&lt;/P&gt;</description>
    <pubDate>Tue, 14 Jan 2020 11:43:45 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-01-14T11:43:45Z</dc:date>
    <item>
      <title>IMPORT 1/2/3/4/5/6/7/8/9/10 days before if file doesn't exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617164#M180797</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;I have list of dates and I need to import files with these dates.&lt;/P&gt;
&lt;P&gt;For example:&lt;/P&gt;
&lt;P&gt;For the dates&amp;nbsp;190125+191117+191214&amp;nbsp; I need to import 3 files: RawTbl1901025,&amp;nbsp;RawTbl191117,RawTbl191214&lt;/P&gt;
&lt;P&gt;The problem is that sometimes the file doesn't exists and then I need to import the file one day before and if not exists then two days before etc....&lt;/P&gt;
&lt;P&gt;Let's say that the loop should Run until 10 days before( because it is impossible that the file doesn't exist more than 10 days before..)&lt;/P&gt;
&lt;P&gt;What is the way to do it please?&lt;/P&gt;
&lt;P&gt;Please note that the dates can be in macro var or in data set&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let vector=190125+191117+191214; 
%let n=3;&lt;BR /&gt;&lt;BR /&gt;/*OR in data set*/&lt;BR /&gt;Data datesTbl;&lt;BR /&gt;input date $;&lt;BR /&gt;cards;&lt;BR /&gt;190125&lt;BR /&gt;191117&lt;BR /&gt;191214&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;
%macro import; 
%do j=1 %to 3;
%let YYMMDD=%scan(&amp;amp;vector.,&amp;amp;j.,+);
data RawTbl&amp;amp;YYMMDD; 
infile  "/pth/ttbl&amp;amp;YYMMDD..TXT" recfm=f LRECL=25;
input 
 Branch s370fib2.
 customerID s370fib4.
 KOD s370fib2.
 Team s370fib2.  
 Type  $ebcdic2. 
;
snif_amt=compress(snif);
date=&amp;amp;YYMMDD;
run;
%mend import;
%import;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 12:00:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617164#M180797</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-01-14T12:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: IMPORT 1/2/3/4/5/6/7/8/9/10 days before if file doesn't exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617165#M180798</link>
      <description>&lt;P&gt;We always advise you to handle dates as integers representing the number of days since 1/1/1960. That way, it becomes very easy to figure out what day is 10 days before 03MAR19, using the INTNX function, or even simpler by plain subtraction of 10.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to go back and re-formulate your solution to do the calculations using actual SAS date values and subtraction. Use formatting to turn the result into something like&amp;nbsp;1901025.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;By the way, what does that 7 digit string 1901025 represent anyway?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 11:43:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617165#M180798</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-14T11:43:45Z</dc:date>
    </item>
    <item>
      <title>Re: IMPORT 1/2/3/4/5/6/7/8/9/10 days before if file doesn't exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617167#M180799</link>
      <description>&lt;P&gt;Sorry, it is&amp;nbsp;&lt;SPAN&gt;1901025 (YYMMDD )&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 12:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617167#M180799</guid>
      <dc:creator>Ronein</dc:creator>
      <dc:date>2020-01-14T12:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: IMPORT 1/2/3/4/5/6/7/8/9/10 days before if file doesn't exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617171#M180801</link>
      <description>&lt;P&gt;Once again, no macro needed, only one macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data datesTbl;
input date :yymmdd6.;
format date yymmddn6.;
cards;
190125
191117
191214
;
run;

proc sql noprint;
select quote('/pth/ttbl'!!put(date,yymmddn6.)!!'.TXT')
into :infiles separated by ','
from datestbl;
quit;
%put &amp;amp;infiles; /* just for checking */

filename infiles (&amp;amp;infiles) recfm=f lrecl=25;

data RawTbl;
length fname $256;
infile infiles filename=fname;
input 
 Branch s370fib2.
 customerID s370fib4.
 KOD s370fib2.
 Team s370fib2.  
 Type  $ebcdic2. 
;
snif_amt=compress(snif);
date = input(substr(fname,length(fname-9),6),yymmdd6.);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and all data goes into one dataset automatically.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 12:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617171#M180801</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-01-14T12:15:58Z</dc:date>
    </item>
    <item>
      <title>Re: IMPORT 1/2/3/4/5/6/7/8/9/10 days before if file doesn't exist</title>
      <link>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617187#M180807</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159549"&gt;@Ronein&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Sorry, it is&amp;nbsp;&lt;SPAN&gt;1901025 (YYMMDD )&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That's still 7 digits, and it is NOT YYMMDD&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 13:15:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/IMPORT-1-2-3-4-5-6-7-8-9-10-days-before-if-file-doesn-t-exist/m-p/617187#M180807</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-14T13:15:58Z</dc:date>
    </item>
  </channel>
</rss>

