<?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 resolve dates file from a txt to sas format in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818101#M322921</link>
    <description>&lt;P&gt;You can use a macro variable to build the filename.&lt;/P&gt;
&lt;P&gt;So set the value into the macro variable and replace the date-like string in the name with a reference to macro variable.&lt;/P&gt;
&lt;P&gt;Note the extra period.&amp;nbsp; The first period marks the end of the name of the macro variable. The second period is the one that becomes part of the filename.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today=20220523 ;
...
   DATAFILE= "/SAS/data/Text/data/GLACNT.&amp;amp;today..TXT"
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So assuming that string represents a date in YYYYMMDD order you can generate such a string using the YYMMDDN format.&lt;/P&gt;
&lt;P&gt;So if you just want today's date:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today=%sysfunc(date(),yymmddn8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want some other date then calculate that date instead.&amp;nbsp; For example if the want the most recent Monday you could use INTNX() with WEEK.2 interval.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let monday=%sysfunc(intnx(week.2,%sysfunc(date()),0),yymmddn8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then use &amp;amp;MONDAY in making the filename.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
   DATAFILE= "/SAS/data/Text/data/GLACNT.&amp;amp;monday..TXT"
...&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 14 Jun 2022 14:39:11 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2022-06-14T14:39:11Z</dc:date>
    <item>
      <title>how to resolve dates file from a txt to sas format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818097#M322917</link>
      <description>&lt;P&gt;Good expects.&lt;/P&gt;
&lt;P&gt;i have the following txt files which are received in a weekly basis (every Monday).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Rixile106_1-1655216440537.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/72275iFB5F768E24E20083/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Rixile106_1-1655216440537.png" alt="Rixile106_1-1655216440537.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i use the import statement to convert the file to sas data format ,however i need to hard code the date every time (every Monday) a new file gets generated, is there a way/ function used in sas that will enable me not to hard code the date&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=""&gt;PROC IMPORT 
     OUT= WORK.GLACNT_IMPORT
     DATAFILE= "/SAS/data/Text/data/GLACNT.20220523.TXT"
     DBMS=DLM REPLACE;
     DELIMITER='|'
     DSD
     LRCEL=12
    GETNAMES=YES;
     DATAROW=2;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 14:30:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818097#M322917</guid>
      <dc:creator>Rixile106</dc:creator>
      <dc:date>2022-06-14T14:30:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to resolve dates file from a txt to sas format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818098#M322918</link>
      <description>&lt;P&gt;What is the question? You have text files, what do you want to do with them?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 14:29:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818098#M322918</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-14T14:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: how to resolve dates file from a txt to sas format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818099#M322919</link>
      <description>&lt;P&gt;i want a function that will enables me to stop hard coding the date everytime a new files gets generated e.g &amp;amp;Yday.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 14:33:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818099#M322919</guid>
      <dc:creator>Rixile106</dc:creator>
      <dc:date>2022-06-14T14:33:09Z</dc:date>
    </item>
    <item>
      <title>Re: how to resolve dates file from a txt to sas format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818101#M322921</link>
      <description>&lt;P&gt;You can use a macro variable to build the filename.&lt;/P&gt;
&lt;P&gt;So set the value into the macro variable and replace the date-like string in the name with a reference to macro variable.&lt;/P&gt;
&lt;P&gt;Note the extra period.&amp;nbsp; The first period marks the end of the name of the macro variable. The second period is the one that becomes part of the filename.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today=20220523 ;
...
   DATAFILE= "/SAS/data/Text/data/GLACNT.&amp;amp;today..TXT"
...&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;So assuming that string represents a date in YYYYMMDD order you can generate such a string using the YYMMDDN format.&lt;/P&gt;
&lt;P&gt;So if you just want today's date:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let today=%sysfunc(date(),yymmddn8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If you want some other date then calculate that date instead.&amp;nbsp; For example if the want the most recent Monday you could use INTNX() with WEEK.2 interval.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let monday=%sysfunc(intnx(week.2,%sysfunc(date()),0),yymmddn8.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And then use &amp;amp;MONDAY in making the filename.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;...
   DATAFILE= "/SAS/data/Text/data/GLACNT.&amp;amp;monday..TXT"
...&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Jun 2022 14:39:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818101#M322921</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-06-14T14:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to resolve dates file from a txt to sas format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818103#M322922</link>
      <description>&lt;P&gt;You should explain more about how any code that is written would know what days/file names to look for. I'm not asking for SAS code, I am asking you to explain in words what the rules are that this code must follow so that the right files can be read in.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or I could guess, but usually that's not as good an idea as you explaining.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 14:40:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818103#M322922</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-06-14T14:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to resolve dates file from a txt to sas format</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818145#M322941</link>
      <description>&lt;P&gt;If these files are supposed to be of the same structure you really should use&amp;nbsp; Data step code to read the files so that the variables have the same characteristics. Every time you run Proc Import it makes guesses as to the type and length of variables and that may change depending on the contents.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jun 2022 16:39:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-resolve-dates-file-from-a-txt-to-sas-format/m-p/818145#M322941</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-06-14T16:39:12Z</dc:date>
    </item>
  </channel>
</rss>

