<?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: Log file into SAS Dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407948#M99463</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65199"&gt;@jei&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Just use &lt;EM&gt;DLM&lt;/EM&gt; instead of &lt;EM&gt;DLMSTR&lt;/EM&gt; and add all THREE delimiters as value (a pipe, backspace, tab).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 524px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16261i2DE19CF0F928C614/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST_LOG;
    LENGTH
        STATUS           $ 13
        TIMESTAMP        8
        EVENT            $ 100
        VAL		 8
       	;
    FORMAT
        STATUS           $CHAR13.
        TIMESTAMP        BEST14.
        EVENT            $100.
        ;
    INFORMAT
        STATUS           $CHAR13.
        TIMESTAMP        BEST14.
        EVENT            $100.
        ;
    INFILE 'c:\temp\TEST.txt'
	      LRECL=32767
        FIRSTOBS=1
        DLM='7c0809'x
        dsd
        TRUNCOVER
		
		;
    INPUT
        STATUS           : $CHAR13.
        TIMESTAMP        : ?? BEST14.
        EVENT            : $100.
        val              : best15.
	;

RUN;
  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 27 Oct 2017 08:28:31 GMT</pubDate>
    <dc:creator>Patrick</dc:creator>
    <dc:date>2017-10-27T08:28:31Z</dc:date>
    <item>
      <title>Log file into SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407580#M99336</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to convert the attached log file into dataset. The log file contains multiple delimiters such as "|" , tab, and a special character (please refer to the attached log file).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help in advance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 08:41:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407580#M99336</guid>
      <dc:creator>jei</dc:creator>
      <dc:date>2017-10-26T08:41:59Z</dc:date>
    </item>
    <item>
      <title>Re: Log file into SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407589#M99340</link>
      <description>&lt;P&gt;Would you be able to outline your target position for the dataset, as that would help someone being able to give you some assistance.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 09:36:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407589#M99340</guid>
      <dc:creator>ClarkLawson</dc:creator>
      <dc:date>2017-10-26T09:36:58Z</dc:date>
    </item>
    <item>
      <title>Re: Log file into SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407600#M99344</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I wish to have the same format of the output on the attached file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 10:55:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407600#M99344</guid>
      <dc:creator>jei</dc:creator>
      <dc:date>2017-10-26T10:55:50Z</dc:date>
    </item>
    <item>
      <title>Re: Log file into SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407658#M99357</link>
      <description>&lt;P&gt;Log files are text. Text manipulation is done with proper tools; SAS and Excel are not proper tools for text.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Oct 2017 14:33:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407658#M99357</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-26T14:33:15Z</dc:date>
    </item>
    <item>
      <title>Re: Log file into SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407921#M99452</link>
      <description>&lt;P&gt;So what did you try?&lt;/P&gt;
&lt;P&gt;Looking at the file you posted in the viewer on this site it looks like text file that delimited with a |.&lt;/P&gt;
&lt;P&gt;It is trivial to read a file that is delimited with | in SAS.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  infile 'myfile.txt' dsd dlm='|' truncover ;
  length var1-var5 $200 ;
  input var1-var5;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;It does appear that one of column appears to contain a list of values delimited by something that looks like a square in the view, but even that should not be hard to deal with once you have the data in a dataset instead of a text file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 05:19:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407921#M99452</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-10-27T05:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Log file into SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407937#M99457</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the code below&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST_LOG;
    LENGTH
        STATUS           $ 13
        TIMESTAMP        8
        EVENT            $ 2577
        VAL		 8
       	;
    FORMAT
        STATUS           $CHAR13.
        TIMESTAMP        BEST14.
        EVENT            $CHAR2577.
        ;
    INFORMAT
        STATUS           $CHAR13.
        TIMESTAMP        BEST14.
        EVENT            $CHAR2577.
        ;
    INFILE 'E:\TEST.log'
	LRECL=32767
        FIRSTOBS=2
        DLMSTR='7C'x
        TRUNCOVER
		
		;
    INPUT
        STATUS           : $CHAR13.
        TIMESTAMP        : ?? BEST14.
        EVENT            : $CHAR2577.
	;
	ARRAY AR[1] EVENT;
		DO i=1 ;
		AR(i)=scan(EVENT, i, '09'X);
		END;


RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and gives the output below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-10-27 at 3.44.21 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16258i80F993A3971D76B2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-27 at 3.44.21 PM.png" alt="Screen Shot 2017-10-27 at 3.44.21 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you can notice, the value whose delimiter is a tab was gone.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried your given code and it gives me the output below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-10-27 at 3.48.02 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16259iD6EF225043DB5F42/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-27 at 3.48.02 PM.png" alt="Screen Shot 2017-10-27 at 3.48.02 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to have another column for the numeric values in&amp;nbsp;&lt;STRONG&gt;var3 column&amp;nbsp;&lt;/STRONG&gt;- which are in the most right. In my code, these values did not appear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So basically, I'm wishing to have like the output below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-10-26 at 5.51.24 PM.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16260iC54D32287D149EE8/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-10-26 at 5.51.24 PM.png" alt="Screen Shot 2017-10-26 at 5.51.24 PM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 07:52:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407937#M99457</guid>
      <dc:creator>jei</dc:creator>
      <dc:date>2017-10-27T07:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Log file into SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407948#M99463</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/65199"&gt;@jei&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;Just use &lt;EM&gt;DLM&lt;/EM&gt; instead of &lt;EM&gt;DLMSTR&lt;/EM&gt; and add all THREE delimiters as value (a pipe, backspace, tab).&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.JPG" style="width: 524px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/16261i2DE19CF0F928C614/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.JPG" alt="Capture.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA TEST_LOG;
    LENGTH
        STATUS           $ 13
        TIMESTAMP        8
        EVENT            $ 100
        VAL		 8
       	;
    FORMAT
        STATUS           $CHAR13.
        TIMESTAMP        BEST14.
        EVENT            $100.
        ;
    INFORMAT
        STATUS           $CHAR13.
        TIMESTAMP        BEST14.
        EVENT            $100.
        ;
    INFILE 'c:\temp\TEST.txt'
	      LRECL=32767
        FIRSTOBS=1
        DLM='7c0809'x
        dsd
        TRUNCOVER
		
		;
    INPUT
        STATUS           : $CHAR13.
        TIMESTAMP        : ?? BEST14.
        EVENT            : $100.
        val              : best15.
	;

RUN;
  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 08:28:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407948#M99463</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2017-10-27T08:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Log file into SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407950#M99464</link>
      <description>&lt;P&gt;Your infile actually has three delimiters:&lt;/P&gt;
&lt;P&gt;- the pipe character&lt;/P&gt;
&lt;P&gt;- hex 08 to separate items in the long string&lt;/P&gt;
&lt;P&gt;- hex 09 to separate events and values within an item&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you need a do loop for the items and two different splits along these separators:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data jei;
infile '$HOME/sascommunity/jei.txt' dlmstr=CRLF dlm='|' truncover;
input
  status :$5.
  TIMESTAMP :$20.
  variablestr :$500.
  n :$1.
;
length
  event $50
  val 8
;
do i = 1 to countw(variablestr,'08'x);
  event = scan(scan(variablestr,i,'08'x),1,'09'x);
  val = input(scan(scan(variablestr,i,'08'x),2,'09'x),best.);
  output;
end;
drop i variablestr;
run;

proc print data=jei noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Partial result:&lt;/P&gt;
&lt;PRE&gt;status      TIMESTAMP       n    event                              val

SV        20170629002459    N    NumberOfUnitsBonded               6729
SV        20170629002459    N    Previous Number of Unit Bonded    6732
SV        20170629002459    N    Number of Unit Bonded             6733
SV        20170629002459    N    UPS                               3433
SV        20170629002459    N    UOL                               6733
SV        20170629002501    N    NumberOfUnitsBonded               6730
SV        20170629002501    N    Previous Number of Unit Bonded    6733
SV        20170629002501    N    Number of Unit Bonded             6734
SV        20170629002501    N    UPS                               3434
SV        20170629002501    N    UOL                               6734
STATE     20170629002501    N    Alarm count per shift                0
STATE     20170629002501    N    Runtime per shift                 8668
STATE     20170629002501    N    MTBA per shift                    8668
SV        20170629002502    N    NumberOfUnitsBonded               6731
SV        20170629002503    N    Previous Number of Unit Bonded    6734
SV        20170629002503    N    Number of Unit Bonded             6735
SV        20170629002503    N    UPS                               3435
SV        20170629002503    N    UOL                               6735
SV        20170629002504    N    NumberOfUnitsBonded               6732
SV        20170629002504    N    Previous Number of Unit Bonded    6735
SV        20170629002504    N    Number of Unit Bonded             6736
SV        20170629002504    N    UPS                               3436
SV        20170629002504    N    UOL                               6736
STATE     20170629002505    N    Alarm count per shift                0
STATE     20170629002505    N    Runtime per shift                 8672
STATE     20170629002505    N    MTBA per shift                    8672
SV        20170629002506    N    NumberOfUnitsBonded               6733
SV        20170629002506    N    Previous Number of Unit Bonded    6736
SV        20170629002506    N    Number of Unit Bonded             6737
SV        20170629002506    N    UPS                               3437
SV        20170629002506    N    UOL                               6737
SV        20170629002508    N    NumberOfUnitsBonded               6734
SV        20170629002508    N    Previous Number of Unit Bonded    6737
SV        20170629002508    N    Number of Unit Bonded             6738
SV        20170629002508    N    UPS                               3438
SV        20170629002508    N    UOL                               6738
&lt;/PRE&gt;
&lt;P&gt;To make the data more analyzable for SAS, consider to convert the timestamp value to a SAS datetime value.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Oct 2017 08:30:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Log-file-into-SAS-Dataset/m-p/407950#M99464</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-10-27T08:30:47Z</dc:date>
    </item>
  </channel>
</rss>

