<?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: SAS Log parser code do not get values from all log files (Interested in SAS EG &amp;amp; AMO users d in Developers</title>
    <link>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773557#M1307</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;You should take care to properly copy/paste code from the web, as my code &lt;A href="https://communities.sas.com/t5/Administration-and-Deployment/query-SAS-Metadata-to-find-list-of-active-users-accessing-SAS/m-p/514696/highlight/true#M15026" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;(which you obviously started with) works. Then start modifying from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to deal with UTF-encoded files, add the ENCODING= option to the INFILE statement. The LRECL and the size of zeile should only be adjusted if really needed.&lt;/P&gt;</description>
    <pubDate>Tue, 12 Oct 2021 07:33:58 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2021-10-12T07:33:58Z</dc:date>
    <item>
      <title>SAS Log parser code do not get values from all log files (Interested in SAS EG &amp; AMO users data)</title>
      <link>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773444#M1305</link>
      <description>&lt;P&gt;Hello All,&lt;BR /&gt;&lt;BR /&gt;I'm having issue to get log parser values of all log files( for Object Spawner logs) for all end users like SAS EG &amp;amp; AMO. And I'm interested in 6 months or old SAS EG &amp;amp; AMO end users data.&lt;BR /&gt;&lt;BR /&gt;Currently,&amp;nbsp;A byte-order mark in the file&lt;BR /&gt;"C:\Users\akhan\Desktop\akhan\ObjectSpawner_2021-10-05_abc_host.log" (for fileref "#LN00008") indicates that the data is encoded in "utf-8". This encoding will be used to process the file.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I just got values from this log&amp;nbsp;ObjectSpawner_2021-10-05_abc_host.log file only. There are 10 more log files but the pointer only point to 1 log file. Please advise&lt;BR /&gt;&lt;BR /&gt;Attached is the SAS code.&lt;BR /&gt;&lt;BR /&gt;Thank you in advance&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Asif&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit by KB, to make the code readable without download:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro read_spawnlog;
data spawnlog;
*infile mylib truncover;
infile "C:\Users\akhan\Desktop\akhan\*.log" lrecl=100000000 dsd;
/*filename pth "&amp;amp;libpath";
%put &amp;amp;libpath;*/
format
  datum ddmmyyp10.
  zeit  time8.
  user  $512.
  port  $512.
  address $512.
  success $1.
;
input
zeile $1024.
;
if index(zeile,"New client connection") &amp;gt; 0;
%if "&amp;amp;sysver" = "9.4"
%then %do;
datum = input(substr(zeile,1,10),yymmdd10.);
zeit = input(substr(zeile,12,8),time8.);
%end;
%else %if "&amp;amp;sysver" = "9.2"
%then %do;
datum = input(substr(zeile,1,10),yymmdd10.);
zeit = input(substr(zeile,12,8),time8.);
%end;
%else %if "&amp;amp;sysver" = "9.1"
%then %do;
datum = input(substr(zeile,1,8),yymmdd8.);
zeit = input(substr(zeile,10,8),time8.);
%end;
%else %do;
abort abend 7;
%end;
pos = index(zeile,"server port");
port = substr(zeile,pos+12,4);
pos = index(zeile,"for user");
if pos ne 0
then do;
  user = substr(zeile,pos+9,5);
  pos = indexc(user,".");
  if pos ne 0 then user = substr(user,1,pos-1);
end;
/*else do;
pos = index(zeile,"server port");
port = substr(zeile,pos+12,5);
pos = index(zeile,"for user");
if pos ne 0
then do;
  user = substr(zeile,pos+9,5);
  pos = indexc(user,".");
  if pos ne 0 then user = substr(user,1,pos-1);
end; */
else do;
  pos = index(zeile,"for SAS token user");
  user = substr(zeile,pos+19);
  pos = indexc(user,"@");
  if pos ne 0 then user = substr(user,1,pos-1);
end;
pos = index(zeile,"port are");
%if "&amp;amp;sysver" = "9.4"
%then %do;
address = substr(zeile,pos+17,15);
pos = indexc(address,"]");
if pos &amp;gt; 0 then address = substr(address,1,pos-1);
/*pos = index(APPNAME,"APPNAME");
APPNAME = substr(zeile,pos+283,140);*/
*pos = index(zeile,"904500");
*if pos &amp;gt; 0 then APPNAME = substr(APPNAME,1,pos-1);
*Details = substr(zeile,pos+250);
*pos = indexc(Details,".");
*APPNAME2 = substr(APPNAME,20,23);
*APPNAME2 = index(APPNAME,"SAS Enterprise Guide");
*APPNAME3 = substr(APPNAME2,pos+20);
*APPNAME2 = scan(Details,3);
*APPNAME3 = scan(Details,4);
*APPNAME4 = scan(Details,5);
*SAS_APPLICATION_Names = catx(' ',APPNAME2,APPNAME3,APPNAME4);
*if pos &amp;gt; 0 then Details = substr(Details,1,pos-1);
*where Details contains 'SAS Enterprise Guide';
*APPNAME2 = index(APPNAME,pos+20);
*APPNAME2 = substr(APPNAME,pos+22);
*pos = indexc(APPNAME2,".");
*if pos &amp;gt; 0 then APPNAME = substr(APPNAME,1,pos-1);
%end;
%else %if "&amp;amp;sysver" = "9.2"
%then %do;
address = substr(zeile,pos+17,15);
pos = indexc(address,"]");
if pos &amp;gt; 0 then address = substr(address,1,pos-1);
%end;
%else %do;

address = substr(zeile,pos+9,15);
pos = indexc(address,":");
if pos &amp;gt; 0 then address = substr(address,1,pos-1);
/*%end;
%else %do;*/
/*SASAPP = substr(zeile,pos+9,15);
pos = indexc(SASAPP,":");
if pos &amp;gt; 0 then address = substr(SASAPP,1,pos-1);*/
%end;
if index(zeile,"rejected") &amp;gt; 0 then success = "N"; else success = "Y";
drop pos;
run;
%mend;
%read_spawnlog;

data work.EGClients(drop=zeile);
set work.Spawnlog;
where zeile contains 'SAS Enterprise Guide';
run;
data work.ADDIn (drop=zeile);
set work.Spawnlog;
where zeile contains 'SAS Add-In for Microsoft Office';
run;
title1 "Enterprise Guide End Users Names List";
proc print data=work.EGClients;
run;

title1 "SAS Add-In End Users Names List";
proc print data=work.ADDIn;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Oct 2021 07:24:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773444#M1305</guid>
      <dc:creator>Asif4862</dc:creator>
      <dc:date>2021-10-12T07:24:04Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Log parser code do not get values from all log files (Interested in SAS EG &amp; AMO users d</title>
      <link>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773549#M1306</link>
      <description>&lt;P&gt;It would help if you'd add the SAS log with mprint and mlogic set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For below portion in your code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    infile "C:\Users\akhan\Desktop\akhan\*.log" lrecl=100000000 dsd;
    ....
    input
      zeile $1024.
    ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Your input statement reads up to 1024 characters per row AND it appears you want to read a single row into a single variable Zeile.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;lrecl should be set to 1024 as you're never reading more than that.&lt;/LI&gt;
&lt;LI&gt;dsd makes no sense&lt;/LI&gt;
&lt;LI&gt;You need to set TRUNCOVER. The default FLOWOWER is certainly not what you need here.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Your code will read all .log files in folder&amp;nbsp;&lt;CODE class=" language-sas"&gt;C:\Users\akhan\Desktop\akhan&lt;/CODE&gt;&amp;nbsp;How many .log files do you have under this folder?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To also keep the information from which log file a row comes consider using infile option FILENAME&lt;BR /&gt;&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm" target="_blank" rel="noopener"&gt;https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/lestmtsref/n1rill4udj0tfun1fvce3j401plo.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&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>Tue, 12 Oct 2021 06:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773549#M1306</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2021-10-12T06:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Log parser code do not get values from all log files (Interested in SAS EG &amp; AMO users d</title>
      <link>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773557#M1307</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;
&lt;P&gt;You should take care to properly copy/paste code from the web, as my code &lt;A href="https://communities.sas.com/t5/Administration-and-Deployment/query-SAS-Metadata-to-find-list-of-active-users-accessing-SAS/m-p/514696/highlight/true#M15026" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;(which you obviously started with) works. Then start modifying from there.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need to deal with UTF-encoded files, add the ENCODING= option to the INFILE statement. The LRECL and the size of zeile should only be adjusted if really needed.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 07:33:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773557#M1307</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2021-10-12T07:33:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Log parser code do not get values from all log files (Interested in SAS EG &amp; AMO users d</title>
      <link>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773743#M1309</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;&amp;nbsp;, your suggested steps did work for me&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Asif&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 19:59:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773743#M1309</guid>
      <dc:creator>Asif4862</dc:creator>
      <dc:date>2021-10-12T19:59:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Log parser code do not get values from all log files (Interested in SAS EG &amp; AMO users d</title>
      <link>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773744#M1310</link>
      <description>&lt;P&gt;Thank you &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt;&amp;nbsp;for your help &amp;amp; assistance. I appreciate it.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Asif&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Oct 2021 20:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Developers/SAS-Log-parser-code-do-not-get-values-from-all-log-files/m-p/773744#M1310</guid>
      <dc:creator>Asif4862</dc:creator>
      <dc:date>2021-10-12T20:01:11Z</dc:date>
    </item>
  </channel>
</rss>

