<?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: working with macro  date or string in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/working-with-macro-date-or-string/m-p/686039#M37078</link>
    <description>&lt;P&gt;You need to convert the text string containing the modify date to a SAS date/time value, you do this via the INPUTN function, and then you can find the month and date. And it probably would be easier in a DATA step, but here it is in the macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro FileAttribs(filename);                                                                                                           
   %local rc fid fidc;                                                                                                                   
   %local Bytes CreateDT ModifyDT;                                                                                                       
   %let rc=%sysfunc(filename(onefile,&amp;amp;filename));                                                                                       
   %let fid=%sysfunc(fopen(&amp;amp;onefile));                                                                                                  
   %let Bytes=%sysfunc(finfo(&amp;amp;fid,File Size (bytes)));                                                                                  
   %let CreateDT=%qsysfunc(finfo(&amp;amp;fid,Create Time));                                                                                     
   %let ModifyDT=%qsysfunc(finfo(&amp;amp;fid,Last Modified));                                                                                   
   %let fidc=%sysfunc(fclose(&amp;amp;fid));                                                                                                    
   %let rc=%sysfunc(filename(onefile));                                                                                                 
   %put NOTE: File size of &amp;amp;filename is &amp;amp;Bytes bytes;                                                                                  
   %put NOTE- Created &amp;amp;CreateDT;                                                                                                       
   %put NOTE- Last modified &amp;amp;ModifyDT;  
   %let modifydt1= %sysfunc(inputn(&amp;amp;modifyDT,anydtdtm.)); 
   %put MONTH= %sysfunc(month(%sysfunc(datepart(&amp;amp;modifydt1))));
   %put DATE= %sysfunc(putn(%sysfunc(datepart(&amp;amp;modifydt1)),date9.));
%mend FileAttribs;       &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 23 Sep 2020 13:43:10 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-09-23T13:43:10Z</dc:date>
    <item>
      <title>working with macro  date or string</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/working-with-macro-date-or-string/m-p/686033#M37076</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;/** Macro technique **/                                                                                                                 
%macro FileAttribs(filename);                                                                                                           
   %local rc fid fidc;                                                                                                                   
   %local Bytes CreateDT ModifyDT;                                                                                                       
   %let rc=%sysfunc(filename(onefile,&amp;amp;filename));                                                                                       
   %let fid=%sysfunc(fopen(&amp;amp;onefile));                                                                                                  
   %let Bytes=%sysfunc(finfo(&amp;amp;fid,File Size (bytes)));                                                                                  
   %let CreateDT=%qsysfunc(finfo(&amp;amp;fid,Create Time));                                                                                     
   %let ModifyDT=%qsysfunc(finfo(&amp;amp;fid,Last Modified));                                                                                   
   %let fidc=%sysfunc(fclose(&amp;amp;fid));                                                                                                    
   %let rc=%sysfunc(filename(onefile));                                                                                                 
   %put NOTE: File size of &amp;amp;filename is &amp;amp;Bytes bytes;                                                                                  
   %put NOTE- Created &amp;amp;CreateDT;                                                                                                       
   %put NOTE- Last modified &amp;amp;ModifyDT;                                                                                                 
%mend FileAttribs;                                                                                                                      
                                                                                                                                        
/** Just pass in the path and file name **/                                                                                             
%FileAttribs(c:\aaa.txt)          &lt;/CODE&gt;&lt;BR /&gt;&lt;BR /&gt;Hello, I am using this macro to get the &amp;amp;ModifyDT. I would like to know what is the format of this macro?&lt;BR /&gt;Can how can we convert it to get only the datepart and from there to get only the month.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Alain&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Sep 2020 13:23:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/working-with-macro-date-or-string/m-p/686033#M37076</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2020-09-23T13:23:43Z</dc:date>
    </item>
    <item>
      <title>Re: working with macro  date or string</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/working-with-macro-date-or-string/m-p/686038#M37077</link>
      <description>&lt;P&gt;You haven't shown any of the values so we have no idea.&lt;/P&gt;
&lt;P&gt;The way the value appears is probably dependent on the operating system the SAS server is using. Windows and Unix might present that information different.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could try using the ANYDTDTE informat to convert it to a date.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let date=%sysfunc(inputn(&amp;amp;ModifyDT,anydtdte24.));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;That should give a value like 22181 which is how SAS stores the date 2020-09-23.&lt;/P&gt;
&lt;P&gt;If you want the value formatted for human consumption instead add a format to the %SYSFUNC() call.&amp;nbsp; You could even use the MONTH or MONNAME format to get the month number or name.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let month=%sysfunc(inputn(&amp;amp;ModifyDT,anydtdte24.),month2.);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 13:43:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/working-with-macro-date-or-string/m-p/686038#M37077</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-23T13:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: working with macro  date or string</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/working-with-macro-date-or-string/m-p/686039#M37078</link>
      <description>&lt;P&gt;You need to convert the text string containing the modify date to a SAS date/time value, you do this via the INPUTN function, and then you can find the month and date. And it probably would be easier in a DATA step, but here it is in the macro&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro FileAttribs(filename);                                                                                                           
   %local rc fid fidc;                                                                                                                   
   %local Bytes CreateDT ModifyDT;                                                                                                       
   %let rc=%sysfunc(filename(onefile,&amp;amp;filename));                                                                                       
   %let fid=%sysfunc(fopen(&amp;amp;onefile));                                                                                                  
   %let Bytes=%sysfunc(finfo(&amp;amp;fid,File Size (bytes)));                                                                                  
   %let CreateDT=%qsysfunc(finfo(&amp;amp;fid,Create Time));                                                                                     
   %let ModifyDT=%qsysfunc(finfo(&amp;amp;fid,Last Modified));                                                                                   
   %let fidc=%sysfunc(fclose(&amp;amp;fid));                                                                                                    
   %let rc=%sysfunc(filename(onefile));                                                                                                 
   %put NOTE: File size of &amp;amp;filename is &amp;amp;Bytes bytes;                                                                                  
   %put NOTE- Created &amp;amp;CreateDT;                                                                                                       
   %put NOTE- Last modified &amp;amp;ModifyDT;  
   %let modifydt1= %sysfunc(inputn(&amp;amp;modifyDT,anydtdtm.)); 
   %put MONTH= %sysfunc(month(%sysfunc(datepart(&amp;amp;modifydt1))));
   %put DATE= %sysfunc(putn(%sysfunc(datepart(&amp;amp;modifydt1)),date9.));
%mend FileAttribs;       &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Sep 2020 13:43:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/working-with-macro-date-or-string/m-p/686039#M37078</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-09-23T13:43:10Z</dc:date>
    </item>
  </channel>
</rss>

