BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
canna_guy_scott
Calcite | Level 5

Hello!

 

At the end of the sas program below, an email is generated and send out with a pdf  containing a GPlot attached.

 

 

data dummy1;
input  admin $char10. x y z;
datalines;
12-12-1952  45 22 1  
12-13-1952  55 32 1  
12-14-1952  66 35 2  
12-15-1952  63 30 2  
12-16-1952  65 34 4  
12-17-1952  . . .  
12-18-1952  . . .          
12-19-1952  . . .          
;

options  missing=' ' nocenter  papersize=legal orientation=portrait nodate nonumber leftmargin=0.3in rightmargin=0.3in;
ods escapechar="^";
title;
ODS PDF file="C:\<insert your path>\file_with_gplot.pdf" startpage=no;
            ods text=" ";
            ods text= "^{style [just=left font=('calibri', 12pt, bold)] Data}";
            ods text=" ";

         proc report data=dummy1 nowd split='~' nowd style(column)={cellheight=0.17in} style(header)={cellheight=0.25in fontsize=6pt fontfamily='calibri'} style(column)=[ fontfamily='calibri' fontsize=6pt];
              title;
              column admin x y z;
              define admin/ display "Date";
              define x/ display "% All" style(column)=[cellwidth=0.7in just=center];
              define y/ display "% Most" style(column)=[cellwidth=0.7in just=center];
              define z/ display "% Some" style(column)=[cellwidth=0.7in just=center];
         run;
    
goptions reset=global gunit=pct border cback=white
         colors=(black blue green red)
         ftitle=swissb ftext=swissb htitle=3.5 htext=2 vsize=3 hsize=3.5  horigin=0 vorigin=6;

title1 'Gplot of X, Y, Z over Date';

symbol1             color=red   interpol=join value=dot height=3;
symbol2 font=marker color=blue  interpol=join value=C   height=3;
symbol3 font=marker color=green interpol=join value=X   height=3;

axis1 label=("The" justify=c
            "Date")
       major=(height=2) minor=(height=1) width=3;
axis2 order=(0 to 100 by 10) offset=(0,0) label=none major=(height=2) minor=(height=1) width=3;
legend1 label=none shape=symbol(4,2) position=(top center inside) mode=share;

proc gplot data=dummy1;
   plot x*admin y*admin z*admin / overlay legend=legend1 haxis=axis1 hminor=4 vaxis=axis2 vminor=1;
run;
quit;

ODS PDF close;


FILENAME OUTBOX EMAIL
    TO        =    ("<insert_your_email>@<xyz.com>")
    REPLYTO    =    ("<insert_your_email>@<xyz.com>")
    SUBJECT    =    ("Test - pdf file with embedded Gplot ")
    ATTACH  =   ("C:\<insert your path>\file_with_gplot.pdf");
DATA _NULL_;
  FILE OUTBOX;
    PUT ;
    PUT %SYSFUNC(COMPBL("This email was generated via sas program."));
    PUT ;
RUN;
FILENAME OUTBOX CLEAR;


data _null_; put '** the SAS job is now finished'; run;
data _null_; file print ; title; put; put '** the SAS job is now finished'; run;


 

 

All works fine (no errors, etc) if you run this program interactively - the pdf is generated, the email with the pdf attached is sent ...

 

We have been trying to schedule this program to run every morning at 5 AM; we were hoping that Windows Task Scheduler would be the ticket. (by the way, I have Window 8.1 Enterprise)

 

(if you haven't used windows task, one key feature is you have windows task scheduler run a windows bat file - and this bat file runs the sas program or programs - below are the contents of  the bat file I am using to run the above sas program (the sas program is named "sas_gplot_pdf_test_task_scheduler.sas"))

 

"C:\Program Files\SASHome\x86\SASFoundation\9.4\sas.exe" -SYSIN "C:\transfer\sas_gplot_pdf_test_task_scheduler.sas"  -LOG "C:\transfer\sas_gplot_pdf_test_task_scheduler.log"  -PRINT "C:\transfer\sas_gplot_pdf_test_task_scheduler.lst"

 

 

And now here is the PROBLEM (sorry for yelling ;-):

 

When the scheduler fires up, it runs the bat file, which launches sas (see image below):

 

 

 

 

task_scheduler_hang.png

 

And then just sits there ("hangs") - the log and print file have been generated, but the pdf has not, and no email has been sent.  It just sits ...

 

The only way I can get things to move forward is to hit the little red "x" for graph window (see image below) - which means this is no longer an automatically scheduled/launched sas program (I don't want to wake up every morning at 5 AM to hit a little red x).

 

I know that in interactive sas one can use either dm "graph; end"; or

proc greplay igout = work.gseg nofs;
delete _all_;
run;
quit;

to clear the Graph 1 Window - but neither seem to work when the sas program is run via Task Scheduler  (i.e., when you are not running interactive sas).

 

Thanks in Advance!

 

 

task_scheduler_hang1.png


1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Add the statement ODS _ALL_ close; before ODS PDF;

PG

View solution in original post

6 REPLIES 6
canna_guy_scott
Calcite | Level 5

Here is the log from the sas job that hangs (when running it using the Windows Task Scheduler).

canna_guy_scott
Calcite | Level 5

And here is the log when running the sas program interactively.

DaveHorne
SAS Employee

Hi @canna_guy_scott, I tried your test program and it actually worked (the ODS PDF part) using 9.4M6 on Windows 10 in batch via the task scheduler.  I think in some earlier releases you have to close the listing output before the other ods options:

 

ods listing close;
PGStats
Opal | Level 21

Add the statement ODS _ALL_ close; before ODS PDF;

PG
canna_guy_scott
Calcite | Level 5

Both suggestions work!  Thank you so much for solving this mystery!

 

To recap the succesful suggestions:

 

Suggestion 1:  Add the statement ODS listing close; before ODS PDF;

Suggestion 2:  Add the statement ODS _ALL_ close; before ODS PDF;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 6 replies
  • 2385 views
  • 0 likes
  • 4 in conversation