<?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: Turning Log Data into Dataset in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385942#M11663</link>
    <description>&lt;P&gt;Try the following code. I added comments to describe what it does. Note that my detection of lines broken by a CRLF in the text might need modification.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
/* The infile comes from DOS and uses CRLF and the pipe character as delimiter */
infile '$HOME/sascommunity/sample_log.txt' lrecl=500 termstr=CRLF dlm='|' truncover;
input f1 :$1. dt_str :$27. textstr :$200.;
if f1 ne ' '; /* filters emtpy lines */
dt = input(substr(dt_str,1,23),e8601dt23.3);
tz = substr(dt_str,25,3);
/* you might want to correct the timestamp according to the timezone, with intnx() */
format dt e8601dt23.3; /* ISO-standard display */
/* now let's test if we have a continuation line caused by a spurious CRLF in the text */
input teststr $200. @1 @@; /* hold the line pointer and reset the column to 1 */
if substr(teststr,1,1) = '08'x
then do;
  textstr = trim(textstr) !! teststr;
  input; /* finish reading the continuation line */
end;
drop dt_str teststr;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS I edited line 11 of your file before importing as it contains a typo in the year (22017). &lt;/P&gt;</description>
    <pubDate>Mon, 07 Aug 2017 06:16:49 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2017-08-07T06:16:49Z</dc:date>
    <item>
      <title>Turning Log Data into Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385545#M11644</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have logs from machines which is in a txt file format and I would like to convert it into SAS dataset or in a tabular form. I have SAS Data Integration and SAS Enterprise Guide in our environment. May I know how&amp;nbsp;it will be possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 01:47:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385545#M11644</guid>
      <dc:creator>jei</dc:creator>
      <dc:date>2017-08-04T01:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: Turning Log Data into Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385550#M11645</link>
      <description>&lt;P&gt;It depends on how sophisticated you want to be. At the most basic, this will work (untested, you'll need to check to see what the longest log records are, I'm assuming 256):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data LogData;&lt;/P&gt;
&lt;P&gt;length LogRecord $256;&lt;/P&gt;
&lt;P&gt;infile "/dir1/dir2/SASlog.log" lrecl=32767;&lt;/P&gt;
&lt;P&gt;input;&lt;/P&gt;
&lt;P&gt;LogRecord = _infile_;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can then get into all sorts of sophisticated fiddles. Try googling "SAS log scraper", and that should give you a ton of ideas.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 02:59:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385550#M11645</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-08-04T02:59:01Z</dc:date>
    </item>
    <item>
      <title>Re: Turning Log Data into Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385577#M11647</link>
      <description>&lt;P&gt;I guess you would have a hard time creating the import step with just a point-and-click interface. You most probably won't get around writing the code yourself, in a code node either in DI Studio or EG.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have done such things, reading performance reports from mainframe into SAS, or from the log of the SAS/SHARE server or the webserver. To give you hints or code snippets, we would need an example of the log.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 06:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385577#M11647</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-08-04T06:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: Turning Log Data into Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385714#M11655</link>
      <description>&lt;P&gt;Thanks, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hadn't thought of trying it using the point and click options. I just gave it a quick test, and assuming all you want is one variable with the entire contents of the log line, the point and click import task works beautifully. I just defined the data as tab-delimited, and I don't believe there are ever any tabs in SAS logs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tom&lt;/P&gt;</description>
      <pubDate>Fri, 04 Aug 2017 16:59:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385714#M11655</guid>
      <dc:creator>TomKari</dc:creator>
      <dc:date>2017-08-04T16:59:57Z</dc:date>
    </item>
    <item>
      <title>Re: Turning Log Data into Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385892#M11660</link>
      <description>Anything is possible, especially when you have SAS.&lt;BR /&gt;The more that you know about the log files the better. Perhaps there's a file specification?&lt;BR /&gt;If it's a common machine source chances are that someone have experience with this task.&lt;BR /&gt;If you have DI Studio that's the preferred tool if this will be a continuous setup.</description>
      <pubDate>Sun, 06 Aug 2017 13:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385892#M11660</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2017-08-06T13:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: Turning Log Data into Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385921#M11661</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;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I masked the log details of the attached samle file but still the format is the same. Hope you can give me a hint to transform it into SAS dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 02:01:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385921#M11661</guid>
      <dc:creator>jei</dc:creator>
      <dc:date>2017-08-07T02:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Turning Log Data into Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385942#M11663</link>
      <description>&lt;P&gt;Try the following code. I added comments to describe what it does. Note that my detection of lines broken by a CRLF in the text might need modification.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
/* The infile comes from DOS and uses CRLF and the pipe character as delimiter */
infile '$HOME/sascommunity/sample_log.txt' lrecl=500 termstr=CRLF dlm='|' truncover;
input f1 :$1. dt_str :$27. textstr :$200.;
if f1 ne ' '; /* filters emtpy lines */
dt = input(substr(dt_str,1,23),e8601dt23.3);
tz = substr(dt_str,25,3);
/* you might want to correct the timestamp according to the timezone, with intnx() */
format dt e8601dt23.3; /* ISO-standard display */
/* now let's test if we have a continuation line caused by a spurious CRLF in the text */
input teststr $200. @1 @@; /* hold the line pointer and reset the column to 1 */
if substr(teststr,1,1) = '08'x
then do;
  textstr = trim(textstr) !! teststr;
  input; /* finish reading the continuation line */
end;
drop dt_str teststr;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;PS I edited line 11 of your file before importing as it contains a typo in the year (22017). &lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 06:16:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Turning-Log-Data-into-Dataset/m-p/385942#M11663</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-08-07T06:16:49Z</dc:date>
    </item>
  </channel>
</rss>

