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

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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.

View solution in original post

6 REPLIES 6
ballardw
Super User

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.

hondahawkrider
Fluorite | Level 6

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

 

 

 

hondahawkrider
Fluorite | Level 6
thx ballardw .. I tired it a few more times and got it
ballardw
Super User

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.

 

 

hondahawkrider
Fluorite | Level 6
Thx.. Im working on it.. I am former SA with lots of bat/vb/bash scripting experience who is now doing performance engineering and new to SAS, I'm more on the practical side (Getting stuff to work), I have a worker who is a statistician and old school sas scriptor. When I do my own it's more modern based as i'm learning on my own as well as from him.. However, I get a lot of base scripts he has written and have to run with em...

Thx again
ballardw
Super User

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.

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
  • 6 replies
  • 934 views
  • 0 likes
  • 2 in conversation