Data visualization with SAS programming

sgplot output error when running SAS 9.4 from a batch file

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

sgplot output error when running SAS 9.4 from a batch file

Hi, 

I am running SAS daily from a batch file to produce a pdf containing a couple of tables, a couple of plots from gplot and then several from sgplot. My program worked in 9.3, but when I updated to 9.4 the tables and the gplot output is produced, but the sgplot output is not and I get "ERROR: Trying to open a key that does not exist: CORE\PRINTING\PRINTERS\\DEFAULT SETTINGS".

This only happens when I run sas from a batch file, not if I open SAS and run from there.

I can't find any reference to sgplots run from batch files other than that ods graphics are off by default in batch mode, but turning ods graphics on in the program doesn't fix my problem.

I would really appreciate any help!

Thanks,

Anne

 

Here is the code I am running:

 

 

options nodate nonumber;
goptions device=pdf border gsfmode=replace hsize=8 vsize=8;
title "LTBE Soil Water Probes";
title2 "&pdate";
ods pdf file="c:\projects\bioenergy\LTBE\data\weather\soil probes &pdate..pdf" pdftoc=1;
ods noproctitle;
 ****tables and gplot code not included************;
ods graphics on;
ods pdf startpage=now;
title "Long-Term Biomass Experiment";
title2 "&pyear";
ods layout gridded width=7in height=8in columns=2 rows=2 order_type=row_major; 
ods region x=0 y=5% width=50% height=50%; 
ods proclabel "Whole Season by Treatment Plots";
ods noproctitle;
proc sgplot data=forplts2 description="Control";
series x=datetime y=CA / legendlabel="Austin" lineattrs=(thickness=1 color=stgy) break; 
series x=datetime y=CH /legendlabel="Houston" lineattrs=(thickness=1 color=deo) break; 
needle x=datetime y=rain_mm /legendlabel="rain" y2axis lineattrs=(thickness=1 color=cyan);
xaxis label=" ";
yaxis label="volumetric soil water content (%)" labelattrs=(size=1.1%) values=(0 to 60 by 10);
y2axis label="mm of water" labelattrs=(size=1.1%) values=(0 to 100 by 10);
title "Treatment = Control"; 
run;
ods region x=50% y=5% width=50% height=50%; 
ods proclabel " ";
proc sgplot data=forplts2 description="Spring drought"; 
series x=datetime y=PPTSDA /legendlabel="Austin" lineattrs=(thickness=1 color=stgy) break; 
series x=datetime y=PPTSDH /legendlabel="Houston" lineattrs=(thickness=1 color=deo) break; 
needle x=datetime y=rain_mm /legendlabel="rain" y2axis lineattrs=(thickness=1 color=cyan);
xaxis label=" ";
yaxis label="volumetric soil water content (%)" labelattrs=(size=1.1%) values=(0 to 60 by 10);
y2axis label="mm of water" labelattrs=(size=1.1%) values=(0 to 100 by 10);
title "Treatment = Spring Drought"; 
run;
ods region x=0 y=42% width=50% height=50%;
ods proclabel " ";
proc sgplot data=forplts2 description="Winter drought";
series x=datetime y=PPTWDA /legendlabel="Austin" lineattrs=(thickness=1 color=stgy) break; 
series x=datetime y=PPTWDH /legendlabel="Houston" lineattrs=(thickness=1 color=deo) break; 
needle x=datetime y=rain_mm /legendlabel="rain" y2axis lineattrs=(thickness=1 color=cyan);
xaxis label=" ";
yaxis label="volumetric soil water content (%)" labelattrs=(size=1.1%) values=(0 to 60 by 10);
y2axis label="mm of water" labelattrs=(size=1.1%) values=(0 to 100 by 10);
title "Treatment = Winter Drought"; 
run;
ods region x=50% Y=42% width=50% height=50%; 
ods proclabel " ";
proc sgplot data=forplts2 description="ET replacement"; 
series x=datetime y=ETA /legendlabel="Austin" lineattrs=(thickness=1 color=stgy) break; 
series x=datetime y=ETH /legendlabel="Houston" lineattrs=(thickness=1 color=deo) break; 
needle x=datetime y=rain_mm /legendlabel="rain" y2axis lineattrs=(thickness=1 color=cyan);
needle x=datetime y=irrig_mm /legendlabel="irrigation" y2axis lineattrs=(thickness=1 color=blue);
xaxis label=" ";
yaxis label="volumetric soil water content (%)" labelattrs=(size=1.1%) values=(0 to 60 by 10);
y2axis label="mm of water" labelattrs=(size=1.1%) values=(0 to 100 by 10);
title "Treatment = ET Replacement";
keylegend /across=4;
run;
 
*season by soil plots;
ods pdf startpage=now;
title "Long Term Biomass Experiment";
title2 "&pyear";
ods layout gridded width=7in height=8in columns=2 rows=2 order_type=row_major; 
ods proclabel "Whole Season by Soil Plots";
ods region x=0 y=5% width=50% height=50%; 
proc sgplot data=forplts2 description="Austin ET and control"; 
series x=datetime y=CA / legendlabel="Control" lineattrs=(thickness=1 color=green) break; 
series x=datetime y=ETA /legendlabel="ET replacement" lineattrs=(thickness=1 color=purple) break; 
needle x=datetime y=rain_mm /legendlabel="rain" y2axis lineattrs=(thickness=1 color=cyan);
needle x=datetime y=irrig_mm /legendlabel="irrigation" y2axis lineattrs=(thickness=1 color=blue);
xaxis label=" ";
yaxis label="volumetric soil water content (%)" labelattrs=(size=1%) values=(0 to 60 by 10);
y2axis label="mm of water" labelattrs=(size=1%) values=(0 to 100 by 10);
title "Soil = Austin"; 
keylegend /across=4;
run;
ods region x=50% y=5% width=50% height=50%; 
ods proclabel " ";
proc sgplot data=forplts2 description="Houston ET and control"; 
series x=datetime y=CH / legendlabel="Control" lineattrs=(thickness=1 color=green) break; 
series x=datetime y=ETH /legendlabel="ET replacement" lineattrs=(thickness=1 color=purple) break; 
needle x=datetime y=rain_mm /legendlabel="rain" y2axis lineattrs=(thickness=1 color=cyan);
needle x=datetime y=irrig_mm /legendlabel="irrigation" y2axis lineattrs=(thickness=1 color=blue);
xaxis label=" ";
yaxis label="volumetric soil water content (%)" labelattrs=(size=1%) values=(0 to 60 by 10);
y2axis label="mm of water" labelattrs=(size=1%) values=(0 to 100 by 10);
title "Soil = Houston";
keylegend /across=4;
run;
ods region x=0 y=45% width=50% height=50%;
ods proclabel " ";
proc sgplot data=forplts2 description="Austin Droughts and control";
series x=datetime y=CA / legendlabel="Control" lineattrs=(thickness=1 color=green) break; 
series x=datetime y=PPTWDA /legendlabel="Winter drt" lineattrs=(thickness=1 color=viy) break; 
series x=datetime y=PPTSDA /legendlabel="Spring drt" lineattrs=(thickness=1 color=vio) break; 
needle x=datetime y=rain_mm /legendlabel="rain" y2axis lineattrs=(thickness=1 color=cyan);
xaxis label=" ";
yaxis label="volumetric soil water content (%)" labelattrs=(size=1%) values=(0 to 60 by 10);
y2axis label="mm of water" labelattrs=(size=1%) values=(0 to 100 by 10);
title "Soil = Austin"; 
keylegend /across=4;
run;
ods region x=50% Y=45% width=50% height=50%; 
ods proclabel " ";
proc sgplot data=forplts2 description="Houston Droughts and control"; 
series x=datetime y=CH / legendlabel="Control" lineattrs=(thickness=1 color=green) break; 
series x=datetime y=PPTWDH /legendlabel="Winter drt" lineattrs=(thickness=1 color=viy) break; 
series x=datetime y=PPTSDH /legendlabel="Spring drt" lineattrs=(thickness=1 color=vio) break; 
needle x=datetime y=rain_mm /legendlabel="rain" y2axis lineattrs=(thickness=1 color=cyan);
xaxis label=" ";
yaxis label="volumetric soil water content (%)" labelattrs=(size=1%) values=(0 to 60 by 10);
y2axis label="mm of water" labelattrs=(size=1%) values=(0 to 100 by 10);
title "Soil = Houston"; 
keylegend /across=4;
run;
ods layout end; 
title;
axis;
ods pdf close;

 

Here is the contents of the batch file:

"c:\program files\SASHome\SASFoundation\9.4\sas.exe" -log "c:\projects\bioenergy\LTBE\data\Daily soil moisture sensors.log" -sysin "c:\projects\bioenergy\LTBE\data\sasdatasets\Daily soil moisture sensors.sas" -config "c:\program files\SASHome\SASFoundation\9.4\sasv9.cfg"


Accepted Solutions
Solution
‎04-04-2016 08:54 AM
New Contributor
Posts: 3

Re: sgplot output error when running SAS 9.4 from a batch file

The problem was solved by SAS support by adding 'ods _all_ close' before the 'ods pdf' statement

and 'goptions device=SASPRTC' before running the sgplot procs.

View solution in original post


All Replies
Grand Advisor
Posts: 9,740

Re: sgplot output error when running SAS 9.4 from a batch file

Have you tried this with just a single SGPLOT call?

Without any macro references?

Specify an explicit style on the ODS PDF statement?

 

I suspect a noteable difference in the default printer settings under the new install for batch, possibly none set.

New Contributor
Posts: 3

Re: sgplot output error when running SAS 9.4 from a batch file

Ballardw,
Thanks for your response. I tried all your suggestions, with no change in my results. Still getting the same error message.
Any other thoughts?
Anne
Solution
‎04-04-2016 08:54 AM
New Contributor
Posts: 3

Re: sgplot output error when running SAS 9.4 from a batch file

The problem was solved by SAS support by adding 'ods _all_ close' before the 'ods pdf' statement

and 'goptions device=SASPRTC' before running the sgplot procs.

New Contributor
Posts: 2

Re: sgplot output error when running SAS 9.4 from a batch file

[ Edited ]

I came across the same problem when trying to send gplot output to my output window and a subsequent sgplot to an (external) emf file.  Instead of "ods _all_ close;" which will close all ods destinations (obvi), you can be more specific and use "ods listing close; ods listing;" in case you want to also include further output to, say, a pdf destination that you opened earlier in your program.  (Note that the "ods listing;" is not required unless you want to immediately restore the listing destination.)  This worked for me.

Post a Question
Discussion Stats
  • 4 replies
  • 367 views
  • 0 likes
  • 3 in conversation