DATA Step, Macro, Functions and more

Sending email - file in use error

Reply
Contributor
Posts: 67

Sending email - file in use error

Hi,

sending email I reveive file in use error on lib.loaded, could anyone plese tell me what`s that mean, and how to handle it? 

 

 

Filename mymail email
    From="example@mail.com"
    Sender="example@mail.com"
    to=( "example@mail.com")
    type='text/html'
    %if     &left_count >0 %then %do;
        Subject="Warning: &Process_name has been finished %sysfunc(putn(%sysfunc(today()),DDMMYYS10.))" encoding=LATIN2;
    %end;
    %if     &left_count=0 %then %do;
        Subject="OK:&Process_name has been finished %sysfunc(putn(%sysfunc(today()),DDMMYYS10.))%sysfunc(putn(%sysfunc(today()),DDMMYYS10.))" encoding=LATIN2;
    %end;

        Data _null_;
            file mymail;
            ods html body=mymail;
            ods text= "Some message" ;
           proc print data=lib.loaded(where=(data_danych=%sysfunc(today())) rename=(importowane="Wczytane  pliki"n));
            var "Wczytane pliki"n;
            run;
            %if     &left_count >0 %then %do;
            ods text= "Some message ";
            proc print data=lib.listed_left;
            run;    
            %end;
            ods text= "Some message";
            ods html close ;
        Run;

Thank you.

 

 

Super User
Posts: 9,560

Re: Sending email - file in use error

Please supply the whole log of the macro, so we can see the message(s) and the missing macro code.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Super User
Posts: 9,200

Re: Sending email - file in use error

There is a whole raft of issues in that code.  

First off you have procedure calls within a datastep which is invalid (proc print within data _null_;

Next up you have macro code in open code - i.e. the macro code is not within a macro.

As such it needs a re-write.  To start with:

%macro em ();

  filename...;

%mend em;

%em;

One your code is within a macro then the macro code can evaluate.  So the %if's will work.

Next up this part:

           ods html body=mymail;

Unitl the close, needs to be its own block, and added.  Check this example:

http://support.sas.com/kb/23/636.html 

Ask a Question
Discussion stats
  • 2 replies
  • 70 views
  • 0 likes
  • 3 in conversation