<?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: How to count from file inside SAS? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711449#M219175</link>
    <description>&lt;P&gt;Well, my question is related to this specific part and I don't have a code afterwards (that's what I'm asking for). If the attachment is correct it will give me the log that I posted. Let's say the attachment file is deleted by a user, then it will print the following in the log:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;FONT&gt;NOTE: The file OK4 is:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; E-Mail Access Device&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;ERROR: Error opening attachment file D:\\TestAttc.xlsx.&lt;BR /&gt;ERROR: Physical file does not exist, &lt;FONT&gt;D:\&lt;/FONT&gt;\TestAttc.xlsx.&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;So my overall goal is to add code and try and check if records have been written or not to the OK4 file.&lt;/FONT&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 14 Jan 2021 13:46:23 GMT</pubDate>
    <dc:creator>sasnewbiexx</dc:creator>
    <dc:date>2021-01-14T13:46:23Z</dc:date>
    <item>
      <title>How to count from file inside SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711419#M219160</link>
      <description>&lt;P&gt;Hi guys!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the following script to send e-mails:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    Filename    OK&amp;amp;id
                    Email   From    =    ("&amp;amp;SENDER")
                            Sender  =    ("&amp;amp;SENDER")
                            To      =    ("&amp;amp;RECEIVER" )
                            Subject =    "&amp;amp;SUBJECT"
                            ATTACH  =    ("&amp;amp;AttachmentPath")
                            ;
    data _null_;
           file OK&amp;amp;id;
 
           PUT "&amp;amp;Content"
            //;
    run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;In the log file I see the following:&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;NOTE: 3 records were written to the file OK4.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The minimum record length was 0.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The maximum record length was 19.&lt;BR /&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT&gt;I want to execute a subsequent data step which is based on if recrods were written to the file because if the mail part fails there's no records written to the file (or at least indicated in the log). Is there a way for me to check how many records are in the file OK4 in my code?&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 11:34:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711419#M219160</guid>
      <dc:creator>sasnewbiexx</dc:creator>
      <dc:date>2021-01-14T11:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to count from file inside SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711429#M219165</link>
      <description>&lt;P&gt;You can use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc printto log="&amp;lt;log file path and name&amp;gt;.log"; run;

     *your code written here;

proc printto; run;

data _null_;
   infile "&amp;lt;log file path and name&amp;gt;.log";
   input line $100.;
    if index(line,"Records") then do;
      /* extract number of records */
   end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jan 2021 12:23:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711429#M219165</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-14T12:23:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to count from file inside SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711435#M219167</link>
      <description>&lt;P&gt;You need to post more details of the code you are running, the step you have posted imho can't write 0 obs.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 12:51:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711435#M219167</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-01-14T12:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to count from file inside SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711449#M219175</link>
      <description>&lt;P&gt;Well, my question is related to this specific part and I don't have a code afterwards (that's what I'm asking for). If the attachment is correct it will give me the log that I posted. Let's say the attachment file is deleted by a user, then it will print the following in the log:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;FONT&gt;NOTE: The file OK4 is:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; E-Mail Access Device&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;ERROR: Error opening attachment file D:\\TestAttc.xlsx.&lt;BR /&gt;ERROR: Physical file does not exist, &lt;FONT&gt;D:\&lt;/FONT&gt;\TestAttc.xlsx.&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT&gt;So my overall goal is to add code and try and check if records have been written or not to the OK4 file.&lt;/FONT&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 14 Jan 2021 13:46:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711449#M219175</guid>
      <dc:creator>sasnewbiexx</dc:creator>
      <dc:date>2021-01-14T13:46:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to count from file inside SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711451#M219177</link>
      <description>&lt;P&gt;You can test if the file exists BEFORE trying to attach it to the email.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if %sysfunc(fileexist("&amp;amp;AttachmentPath")) %then %do;
... send email ...
%end;
%else %do;
... write note ...
%end;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 14 Jan 2021 13:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711451#M219177</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-01-14T13:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to count from file inside SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711452#M219178</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259057"&gt;@sasnewbiexx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Well, my question is related to this specific part and I don't have a code afterwards (that's what I'm asking for). If the attachment is correct it will give me the log that I posted. Let's say the attachment file is deleted by a user, then it will print the following in the log:&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;FONT&gt;NOTE: The file OK4 is:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; E-Mail Access Device&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;ERROR: Error opening attachment file D:\\TestAttc.xlsx.&lt;BR /&gt;ERROR: Physical file does not exist, &lt;FONT&gt;D:\&lt;/FONT&gt;\TestAttc.xlsx.&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;So my overall goal is to add code and try and check if records have been written or not to the OK4 file.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Please post the full log.&lt;/P&gt;
&lt;P&gt;It is not clear what you have run.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Pay attention OK4 and the log file created by&amp;nbsp;&lt;STRONG&gt;proc printto&lt;/STRONG&gt; are different files.&lt;/P&gt;
&lt;P&gt;Running the code as you first posted should crate a file probably like&lt;/P&gt;
&lt;PRE&gt;&amp;lt;sender mail&amp;gt;
&amp;lt;recipient mail&amp;gt;
&amp;lt;contents given&amp;gt;
&amp;lt;space line as a result of PUT ...//&amp;gt; &lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 14:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711452#M219178</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-14T14:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to count from file inside SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711454#M219180</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Remote submit to MYNODE commencing.
247   Filename OK&amp;amp;id Email From = ("&amp;amp;SENDER") Sender = ("&amp;amp;SENDER") To = ("&amp;amp;RECEIVER" ) Subject =
247! "&amp;amp;SUBJECT" ;
248   data _null_;
249   file OK&amp;amp;id;
250   PUT "&amp;amp;Content" //;
251   run;
NOTE: The file OK4 is:
      E-Mail Access Device
Message sent
      To:          "email@email.com"
      Cc:
      Bcc:
      Subject:     TestExternal
      Attachments:
NOTE: 3 records were written to the file OK4.
      The minimum record length was 0.
      The maximum record length was 19.
NOTE: DATA statement used (Total process time):
      real time           0.18 seconds
      cpu time            0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This is the log. Can this file OK4 be saved somewhere (in a library) or be read from a the code?&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 14:06:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711454#M219180</guid>
      <dc:creator>sasnewbiexx</dc:creator>
      <dc:date>2021-01-14T14:06:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to count from file inside SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711470#M219185</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/259057"&gt;@sasnewbiexx&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Well, my question is related to this specific part and I don't have a code afterwards (that's what I'm asking for). If the attachment is correct it will give me the log that I posted. Let's say the attachment file is deleted by a user, then it will print the following in the log:&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;&lt;FONT&gt;NOTE: The file OK4 is:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; E-Mail Access Device&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;ERROR: Error opening attachment file D:\\TestAttc.xlsx.&lt;BR /&gt;ERROR: Physical file does not exist, &lt;FONT&gt;D:\&lt;/FONT&gt;\TestAttc.xlsx.&lt;BR /&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT&gt;So my overall goal is to add code and try and check if records have been written or not to the OK4 file.&lt;/FONT&gt;&lt;/DIV&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you don't need to run code &lt;STRONG&gt;after&lt;/STRONG&gt; sending the mail, you need to change the code, so that the mail is only send, if the attachment exists. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt; posted a solution for this problem.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jan 2021 15:11:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711470#M219185</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2021-01-14T15:11:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to count from file inside SAS?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711471#M219186</link>
      <description>Yes, you are right &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15475"&gt;@andreas_lds&lt;/a&gt;. &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;'s answer actually does the job for me! Thank you very much for the help!</description>
      <pubDate>Thu, 14 Jan 2021 15:15:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-count-from-file-inside-SAS/m-p/711471#M219186</guid>
      <dc:creator>sasnewbiexx</dc:creator>
      <dc:date>2021-01-14T15:15:29Z</dc:date>
    </item>
  </channel>
</rss>

