BookmarkSubscribeRSS Feed
Matt3
Quartz | Level 8

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.

 

 

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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 

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1620 views
  • 0 likes
  • 3 in conversation