<?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: written out epoch time stamp of UNIX to sas timestamp in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748624#M235117</link>
    <description>&lt;P&gt;That's unfortunate. Your server admins should install the whole GNU coreutils package, it contains a lot of very useful tools (e.g. /usr/linux/bin/date has a lot of VERY USEFUL options for handling dates in shell scripts).&lt;/P&gt;
&lt;P&gt;Use the built-in SAS functions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mod_time;
length fref $8;
rc = filename(fref,"/sas/conf/Lev1/Web/Logs/SASServer1_1/SASWebReportStudio4.4.log.2021-06-15");
fid = fopen(fref);
if fid ne 0
then do;
  timestamp = input(finfo(fid,foptname(fid,5)),nldatm.);
  rc = fclose(fid);
end;
rc = filename(fref);
format timestamp e8601dt19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You need to use the NLS informat because the FINFO function returns the timestamp in your locale.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Jun 2021 07:35:34 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-06-17T07:35:34Z</dc:date>
    <item>
      <title>written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748382#M235054</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get the "last modified" timestamp of a file residing in a AIX filesytem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I use this AIX-command:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;istat SASWebReportStudio4.4_KeyActions.log | grep modified |  awk '{print $3, $4, $5,  $6, $7, $8}'&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I get this output:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Wed Jun 16 17:35:28 CEST 2021&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can someone tell me, how the heck I can get this into a decent SAS timestamp?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 15:51:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748382#M235054</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-06-16T15:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748386#M235056</link>
      <description>&lt;P&gt;/usr/linux/bin/ls provides a GNU ls with the option --time-style, which allows you to get ISO-compliant timestamps (which you can read with E8601/B8601 infornats).&lt;/P&gt;</description>
      <pubDate>Wed, 16 Jun 2021 16:23:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748386#M235056</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-16T16:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748620#M235114</link>
      <description>&lt;P&gt;Good morning&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;unfortunately, I cannot find the GNU ls version under &lt;SPAN&gt;/usr/linux/bin/ls. Here is, what we have:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="ls_not_there.JPG" style="width: 326px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60442i38EF6C2DA7FF0B15/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ls_not_there.JPG" alt="ls_not_there.JPG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Is there any other way?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 06:49:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748620#M235114</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-06-17T06:49:05Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748624#M235117</link>
      <description>&lt;P&gt;That's unfortunate. Your server admins should install the whole GNU coreutils package, it contains a lot of very useful tools (e.g. /usr/linux/bin/date has a lot of VERY USEFUL options for handling dates in shell scripts).&lt;/P&gt;
&lt;P&gt;Use the built-in SAS functions:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mod_time;
length fref $8;
rc = filename(fref,"/sas/conf/Lev1/Web/Logs/SASServer1_1/SASWebReportStudio4.4.log.2021-06-15");
fid = fopen(fref);
if fid ne 0
then do;
  timestamp = input(finfo(fid,foptname(fid,5)),nldatm.);
  rc = fclose(fid);
end;
rc = filename(fref);
format timestamp e8601dt19.;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You need to use the NLS informat because the FINFO function returns the timestamp in your locale.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Jun 2021 07:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748624#M235117</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-17T07:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748848#M235241</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;: one follow-up question:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using your code, I get the filoption number 5 (Last Modified Date) without any seconds, which in turn creates a time stamp assuming that the seconds part is zero:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;LastModified&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;timestamp&lt;BR /&gt;18. Juni 2021 10.53 Uhr 1939632780&lt;BR /&gt;20. Mai 2021 02.31 Uhr 1937097060&lt;BR /&gt;22. Mai 2021 02.31 Uhr 1937269860&lt;BR /&gt;24. Mai 2021 02.31 Uhr 1937442660&lt;BR /&gt;26. Mai 2021 02.31 Uhr 1937615460&lt;BR /&gt;30. Mai 2021 02.31 Uhr 1937961060&lt;BR /&gt;01. Juni 2021 02.31 Uhr 1938133860&lt;BR /&gt;03. Juni 2021 02.31 Uhr 1938306660&lt;BR /&gt;05. Juni 2021 22.09 Uhr 1938550140&lt;BR /&gt;12. Juni 2021 02.31 Uhr 1939084260&lt;BR /&gt;16. Juni 2021 02.31 Uhr 1939429860&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is this due to the formats used? Woulde Do I have to change the widths of the respective formats?&lt;/P&gt;&lt;P&gt;How can I get the sconds part of the last modified date?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When looking at OS level, I can see that the seconds part should be "15", "45", "45", .... .&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="lm_os_level.JPG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60467i55084845D4559A20/image-size/medium?v=v2&amp;amp;px=400" role="button" title="lm_os_level.JPG" alt="lm_os_level.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 09:21:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748848#M235241</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-06-18T09:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748904#M235269</link>
      <description>&lt;P&gt;Then we need to go back to the istat output.&lt;/P&gt;
&lt;P&gt;Use the SCAN function to get the pieces.&lt;/P&gt;
&lt;P&gt;The 3rd, 2nd and 5th concatenated can be INPUT with DATE9., and the 4th INPUT with TIME8. Then combine both with the DHMS function.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 14:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/748904#M235269</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-18T14:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/750757#M236201</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the problem with using the istat-command way is, that you cannot give a wildcard-search for ALL KeyAction Logs ("&lt;CODE class=" language-sas"&gt;Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log&lt;FONT face="arial black,avant garde" color="#993300"&gt;*&lt;/FONT&gt;&lt;/CODE&gt;"), because the command expects a specific, unique path to ONE file.&lt;/P&gt;&lt;P&gt;Therefore, I will have to iterate through all the KeyActions-Logfiles...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Nevertheless, the command and the transformation of the feedback of istat-command works:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET l_cmd = %nrbquote(istat /please/put/your/path/here/config/LevX/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log | grep modified |  awk '{print $3, $4, $5,  $6, $7, $8}');

/*set up pipe*/
filename oscmd pipe "&amp;amp;l_cmd.";

data work.test   ;
infile oscmd truncover;
input string $50. ;

format timestamp datetime25. date date9. time time8.;

date = input(scan(string,3)||scan(string,2)||scan(string,6),date9.);
time = input(scan(string,4), time8.);

timestamp = dhms(date, hour(time), minute(time), second(time));
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Jun 2021 08:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/750757#M236201</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-06-28T08:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/750913#M236282</link>
      <description>&lt;P&gt;You can do this in one data step by use of the dynamic pipe:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lognames;
infile datalines truncover;
input logfilepath $255.;
datalines;
/sas/conf/Lev1/Web/Logs/SASServer1_1/SASWebReportStudio4.4_KeyActions.log
;

data work.test;
set lognames;
length command $1000;
command = catx(" ","istat",logfilepath,"| grep modified |  awk '{print $3, $4, $5,  $6, $7, $8}'");
format timestamp datetime25. date date9. time time8.;
infile dummy pipe filevar=command end=done truncover;
do until (done);
  input string $50. ;
  date = input(scan(string,3)||scan(string,2)||scan(string,6),date9.);
  time = input(scan(string,4), time8.);
  timestamp = dhms(date, hour(time), minute(time), second(time));
  output;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Jun 2021 07:31:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/750913#M236282</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-06-29T07:31:34Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/751484#M236568</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;: Very elegant! However, this assumes, that I have to MANUALLY write every Logfilename into the datalines Statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data lognames ;
infile datalines truncover;
input logfilepath $255.;
datalines;
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210601_023145
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210603_023144
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210605_220912
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210612_023145
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210616_023148
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210619_023144
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210622_023142
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210624_023144
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210627_023144
/sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/SASWebReportStudio4.4_KeyActions.log_20210701_023144
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there a way to AUTOMATICALLY let sas "fill in" the dataline lines? Maybe somehow with call execute?&lt;/P&gt;&lt;P&gt;So far, I can generate a dataset that list all the Logfiles:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET KeyActionPath = /sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/;
%LET KeyActionLogname = SASWebReportStudio4.4_KeyActions.log;
%LET ls_cmd = %nrbquote(ls -l &amp;amp;KeyActionPath.&amp;amp;KeyActionLogname.* |  awk '{ print $9 }');

/*set up pipe*/
filename oscmd pipe "&amp;amp;ls_cmd.";

data work.Liste_KeyactionLogs   ;
infile oscmd truncover;
input  logfilepath $255.  ;
run;

filename oscmd clear;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Voila:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="Table_Logfilelist.JPG" style="width: 783px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/60876i08689ECFCAFEEFA2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Table_Logfilelist.JPG" alt="Table_Logfilelist.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;But how can I "plug in" this list into the datalines statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 15:22:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/751484#M236568</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-07-01T15:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/751511#M236587</link>
      <description>You already have it! Your dataset is the same as my lognames dataset, just use it in the data step with the dynamic pipe.</description>
      <pubDate>Thu, 01 Jul 2021 17:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/751511#M236587</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-07-01T17:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: written out epoch time stamp of UNIX to sas timestamp</title>
      <link>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/751565#M236599</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;: of course! Vor lauter Bäumen den Wald nicht gesehen!&lt;/P&gt;&lt;P&gt;Here is the complete (dense) code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%LET KeyActionPath = /sas_install_web_p/config/Lev3/Web/Logs/SASServer2_1/;
%LET KeyActionLogname = SASWebReportStudio4.4_KeyActions.log;
%LET ls_cmd = %nrbquote(ls -l &amp;amp;KeyActionPath.&amp;amp;KeyActionLogname.* |  awk '{ print $9 }');

/*set up pipe*/
filename oscmd pipe "&amp;amp;ls_cmd.";

data work.KeyactionLogs_mit_ZS (keep=logfilepath timestamp);
infile oscmd truncover;
input  logfilepath $255.  ;
length command $1000;
command = catx(" ","istat",logfilepath,"| grep modified |  awk '{print $3, $4, $5,  $6, $7, $8}'");
format timestamp datetime25. date date9. time time8.;
infile dummy pipe filevar=command end=done truncover;
do until (done);
  input string $50. ;
  date = input(scan(string,3)||scan(string,2)||scan(string,6),date9.);
  time = input(scan(string,4), time8.);
  timestamp = dhms(date, hour(time), minute(time), second(time));
  output;
end;
run;

filename oscmd clear;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you, Kurt!&lt;/P&gt;</description>
      <pubDate>Thu, 01 Jul 2021 20:23:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/written-out-epoch-time-stamp-of-UNIX-to-sas-timestamp/m-p/751565#M236599</guid>
      <dc:creator>FK1</dc:creator>
      <dc:date>2021-07-01T20:23:40Z</dc:date>
    </item>
  </channel>
</rss>

