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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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