I am using the following code that creates a SAS/Graph jpeg (used to be png) file for all my output from "proc gplot data= all"
* THis is what creates the graph picture automatically; *ods _all_ close; ods listing; * filename grafout "C:\Prod Ack Gen Time Data\2016\GZ\02.24.16\Test.png"; filename grafout ( "&filesout" ); goptions reset=goptions device=JPEG gsfname=grafout gsfmode=append ; *filename grafout clear; run;
my issue is that I have added another gplot to the script, ie "proc gplot data= accesst.all2" and the second graph is parameterized as "
&filestrendout"
What I need is to get an addtional SAS/Graph jpeg (or png) file created (it shows up correctly in my Results tab)
However what ever I try doesn't work (adding &filestrendout to ODS, seperate ODS listing, etc), i only ever get 1 file and it's "&filesout" data (but it sometime uses the &filestrendout parameter setting).. I suspect my initial ODS listing uses some kind default naming convention and only gets me the "proc gplot data= all" graph, but I need both it and "proc gplot data= accesst.all2" as png or jpeg files.. It can be seperate files, or both graphs can be in the same file - doesn't matter...
Here is "proc gplot data= all"
proc gplot data= all ; format int_dt datetime10. ; *title1 "Submission Processing Control Chart" ; title1 "Federal Latency (PROD) Chart" ; *title2 "Mean Latency, Receipts " ; title2 "Period: &begdt to &enddt" ; title3 "Data grouped in &sync_int Second Intervals" ; label int_dt = 'Date Time' ; label latency_mean_seconds= 'latency' ; /* Receipts IMF_Acks BMF_Acks FED_Acks State_Acks Total_Acks RFP Acks_RFP receipt_cnt latency_mean_seconds legend2 order=('Rec' 'Total_Acks'); */ *legend1 order=('latency_lclm' 'latency_mean_seconds' 'latency_uclm'); *legend1 order=('latency_mean_seconds' 'latency_95th_percentile'); legend1 order=('latency' 'latency_lclm' 'latency_mean' 'latency_uclm'); /* legend2 order=('Acks_RFP'); */ legend2 order=('receipt_cnt'); axis1 label=(angle=90 'Latency in Seconds') ; *legend2 order=('Receipts'); plot /**/ latency_lclm*int_dt /* */ latency_mean*int_dt latency_uclm*int_dt latency_mean_seconds*int_dt /*** latency_95th_percentile*int_dt ***/ /** latency_uclm*int_dt * */ / overlay name="tgraph" hminor=0 legend=legend1 haxis=&begdt to &enddt by &ginterval vaxis=axis1 ; /*** plot2 Acks_RFP*int_dt / overlay name="tgraph" legend=legend2 ***/ /***/ plot2 receipt_cnt*int_dt / overlay name="tgraph" legend=legend2 /***/ ; *by date ; run;
Here is proc gplot data= accesst.all2
proc gplot data= accesst.all2 ; format int_dt datetime10. ; title1 "Submission Processing Control Chart Trend" ; *title2 "Mean Latency, Receipts " ; title2 "Period: &begdt_tr to &enddt_tr" ; title3 "Data grouped in &sync_int Second Intervals" ; label int_dt = 'Date Time' ; label latency_mean_seconds= 'latency' ; *legend1 order=('latency' 'latency_lclm' 'latency_mean' 'latency_uclm'); legend1 order=('latency'); legend2 order=('Acks_RFP'); axis1 label=(angle=90 'Latency in Seconds') logbase=10 logstyle=expand ; *legend2 order=('Receipts'); plot /** latency_lclm*int_dt latency_mean*int_dt latency_uclm*int_dt */ latency_mean_seconds*int_dt /*** latency_95th_percentile*int_dt ***/ /** latency_uclm*int_dt * */ / overlay name="tgraph" hminor=0 legend=legend1 haxis=&begdt_tr to &enddt_tr by &ginterval_tr vaxis=axis1 ; /*** plot2 Acks_RFP*int_dt / overlay name="tgraph" legend=legend2 ***/ ; *by date ; run;
I don't know if it's "tgraph" being used in each or what.... I'm stumped .... Help..
Original script is in https://communities.sas.com/t5/Base-SAS-Programming/SAS-Automation-Export/m-p/315194/highlight/true#...
thanks in advance
If I understand what your are attempting there are at least two ways to go:
You should have two Filename statements one referencing each output string.
And then
Before the second Gplot reference the second filename in another goptions statemetn to set the gsfname.
or have another filename statement AFTER the first gplot redefining the filename to point to the other file definition.
the Name= shouldn't matter as that is the name for the entry in the gout catalog and is likely getting incremented to tgraph2, tgraph3 etch each time the code is run;
You have so much code commented out that it is a tad difficult to figure out what you are actually using though.
If I understand what your are attempting there are at least two ways to go:
You should have two Filename statements one referencing each output string.
And then
Before the second Gplot reference the second filename in another goptions statemetn to set the gsfname.
or have another filename statement AFTER the first gplot redefining the filename to point to the other file definition.
the Name= shouldn't matter as that is the name for the entry in the gout catalog and is likely getting incremented to tgraph2, tgraph3 etch each time the code is run;
You have so much code commented out that it is a tad difficult to figure out what you are actually using though.
Yep, I have two Filename statements one referencing each output string - there are
&filesout
and
&filestrend..
I believe I have tried both of you suggestions but I think it might be the way I have done it...
Here is the code cleaned up..
run ;
/**/
symbol1 interpol=join width=1 line=2 v=none color=red;
symbol2 interpol=join width=1 line=1 v=none color=black;
symbol3 interpol=join width=1 line=2 v=none color=red;
symbol4 interpol=join width=1 line=1 v=none color=blue;
symbol5 interpol=join width=1 line=1 v=none color=green;
run;
* THis is what creates the graph picture automatically;
ods listing;
filename grafout (
"&filesout"
);
goptions reset=goptions device=JPEG gsfname=grafout gsfmode=append
;
run;
proc gplot data= all ;
format int_dt datetime10. ;
title1 "Federal Latency (PROD) Chart" ;
title2 "Period: &begdt to &enddt" ;
title3 "Data grouped in &sync_int Second Intervals" ;
label int_dt = 'Date Time' ;
label latency_mean_seconds= 'latency' ;
legend1 order=('latency' 'latency_lclm' 'latency_mean' 'latency_uclm');
legend2 order=('receipt_cnt');
axis1 label=(angle=90 'Latency in Seconds') ;
plot
/**/ latency_lclm*int_dt /* */
latency_mean*int_dt
latency_uclm*int_dt
latency_mean_seconds*int_dt
/ overlay name="tgraph" hminor=0 legend=legend1
haxis=&begdt to &enddt by &ginterval vaxis=axis1
;
plot2 receipt_cnt*int_dt
/ overlay name="tgraph" legend=legend2 /***/
;
run;
proc export
data=ALL
outfile="&filesoutcsv"
dbms=csv
replace
;
run;
** Ive tried filename grafout here and it didn't work;
proc gplot data= accesst.all2 ;
format int_dt datetime10. ;
title1 "Submission Processing Control Chart Trend" ;
title2 "Period: &begdt_tr to &enddt_tr" ;
title3 "Data grouped in &sync_int Second Intervals" ;
label int_dt = 'Date Time' ;
label latency_mean_seconds= 'latency' ;
legend1 order=('latency');
legend2 order=('Acks_RFP');
axis1 label=(angle=90 'Latency in Seconds') logbase=10 logstyle=expand ;
plot latency_mean_seconds*int_dt
/ overlay name="tgraph" hminor=0 legend=legend1
haxis=&begdt_tr to &enddt_tr by &ginterval_tr vaxis=axis1;
;
run;
;
the script exports &fileout fine, but i can't get it to give me another file for &filestrend using the same command later on in the script
You have enough macro variables that things may have hiccupped on you.
You may consider using
options Mprint symbolgen;
before your code the next time you run into an issue. You may find something like a file path with an extra character.
And the occational Goptions reset=all; has been known to correct a number of unexpected behaviors.
You will also want to consider moving over to SGPLOT and other SG procedures as the old device based SAS/Graph general graphing procedures aren't where SAS is spending much time in improvements.
The features available in the newer procedures, especially the GTL, make possible things that required extemely complex annotate data (if possible even then) with the older procedures much simpler.
You may want to look at, and share with your colleage, this link for some examples:
http://support.sas.com/sassamples/graphgallery/PROC_SGRENDER_Graph_Template_Language__GTL_.html
I would have loved to have the ability to do example 35177 20 years ago when I was working with weather data. And the bivariate display in 35172 is very slick for displaying the combined density of two varibles.
SGPanel making multiple similar graphs together with common axis has made some things way easier than Proc Gplot or Gchart.
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 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: