Could anyone please tell me if a PROC SGPANEL will create two picture file of the same kind?
Details:
I have a program that creates graphs using Proc Sgpanel. But it is creates 2 picture files exactly the same. But all I want is to create only one picture file not two...
If this explanation is not enough please let me know so I can elaborate it...
Thanks
I don't follow everything in your post, but the bottom line is:
- if you call proc gpanel and have 2 HTML destinations open, you'll create 2 image files.
- if you call proc gpanel twice and have 2 HTML destinations open, you'll create 4 image files.
What is bothering you with this? Do you want successive proc gpanel calls to write to the same image?
If so, this is not how SAS graphics work.
What you can do though is use proc greplay to combine graphic outputs.
It will be painful though, because 1) EG makes it difficult by not showing catalog entries, and 2) ODS does not create a gseg catalog entries, so you must use SAS/GRAPH. Why so many dumb limitations I don't know, so be patient if you go this route.
There is a discussion here: https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Graphics-and-proc-greplay/td-p/58932
It will help greatly to show the code used to generate the graphs and the actual result obtained. You can attach image and text files to your post, PNG would be best for images..
You should be prepared to discuss the data.
And if you only want one graph then maybe you should be looking at SGPLOT.
Thanks Ballardw for the reply...I need to have a couple of graphs together in one picture file. That is why I have to use sgpanel...
It looks like you have several ODS destinations open, like LISTING and HTML?
If so, close them all and open just the one you need.
Hi ChrisNZ,
Thanks for the reply...I do have two ods html opened. But they have their own unique id...I need to keep two ods destinations open for the reports to be in two different forms...Could you please suggest me some thing to suppress the other generation of the picture file...
Thanks
This can happen if you have two ODS destinations opened associated with the same graphic file type, such as the LISTING and HTML destinations.
Thanks PGStats for the reply...Like I said to chrisNZ, I do have 2 ods html with (id=)opened to create one report in two different formats/ways. Do you think there is a way to suppress the generation of one of the picture?
Hi ChrisNZ,
The code is for this program is really big and has got lots of macro calls too. I have taken the part that is relevent here.
ods html(id=3)
path=;
gpath=;
run;
data _null_;
"a list of things to run from a dataset; more like list to do:LIST1";
run;
Macro1;
data _null_;
"a list of things to run from inside LIST1. more like a sub list: LIST2";
run;
ods html (id=4)
path=;
gpath=;
run;
ods graphics on/
''(some options)
''
;
proc sgpanel data=;
panel by.....;
run;
ods html (id=4) close;
mend Macro1;
ods html (id=3) close;
Hope I did not confuse you with the code...
Thanks
Hi:
Your code is NOT helpful at all. Having the %MACRO and %MEND inside the ODS HTML call is not useful. The steps inside the MACRO program will not be generated or sent to the compiler until the macro program is invoked. You are only showing the skeleton of a program. Here are 2 real examples of using SGPANEL with ODS HTML and showing the code simply without using MACRO:
ods html file='sgpanel_examp.html';
title 'Two Charts';
footnote;
proc sgpanel data=sashelp.prdsale ;
panelby division;
vbar product / response=actual stat=mean limits=upper limitstat=clm attrid=myid group=product;
run;
proc sgpanel data=sashelp.heart;
panelby chol_status;
scatter x=diastolic y=systolic / group=sex;
run;
ods html close;
The first example uses SASHELP.PRDSALE and does a VBAR chart side by side. There are only 2 values for DIVISION, so this makes 2 panels side by side, one for each division.
The second example uses SASHELP.HEART. The variable CHOL_STATUS has 3 possible values, when I allow SGPANEL to do the arranging, it makes an arrangement of 4 panels, with 3 of the panels filled. I could change that arrangement with options in the PANELBY statement. My code can be copied and run because every SAS installation has the SASHELP library. SASHELP.HEART has been part of SASHELP since SAS 9.2, which is when SGPANEL came out, so can you come up with an example that SHOWS what your issue is with SGPANEL? As you can see when you run my program, SGPANEL will automatically arrange the panels based on the number of PANELBY variable values it detects.
We need to have code so we can actually see what you're creating. It doesn't have to be with your data. Use some SASHELP data. There are 200 datasets there. Is your PANELBY variable "predictable" are there always 2 values, or 3 values or 4 values or can the number of PANELBY variable change? You can at least share WHAT the statement is that is inside your SGPANEL procedure? Is it a VBAR statement, a SCATTER, a HISTOGRAM? You are asking for help, but we need more, real information from you in order to help.
cynthia
Hi Cynthia,
I appologize for the confusion. I have issues running sas in my Laptop and the other place I have access is my work computer. This is the reason why I cant copy paste the code...
I wanted to give you the skeleton structure coz its easy to know what is happening in little code that I can provide...
ods html (id=3) file="test_graph_major.html"
path="c:\graph"
gpath="c:\graph\pic" ;
data _null_;
"LIST1";
run;
Macro graph1;
data _null_;
" LIST2";
run;
ods html (id=4) file="test_graph_minor.html"
path="c:\graph"
gpath="c:\graph\pic" ;
ods graphics on/ reset=index imagfmt=png imagename=chart;
title 'test chart';
proc sgpanel data= sashelp.cars;
panel by Type/ onepanel columns=5 novarname;
vbar MSRP / response=horsepower stat=mean;
colaxis fitpolicy=staggerithin;
run;
ods graphics off;
ods html (id=4) close;
mend Graph1;
%Graph1;
ods html (id=3) close;
Cinthia, the LIST1 and LIST2 are difficult to explain by typing,but I will try to do my best to explain
LIST1
name age sex height batch
ren 12 m 111 a
zen 23 f 122 a
sam 43 m 143 b
liv 52 f 165 b
LIST2
name sex batch
ren m a
zen f a
sam m b
liv f b
Explanation:
Html (id=3) will use LIST1 based on "NAME", this creates one charts per NAME value
Html(id=4) will use LIST2 based on "BATCH", hence 2 charts are made per BATCH value
Hope this helps Cynthia...
Thanks
I don't follow everything in your post, but the bottom line is:
- if you call proc gpanel and have 2 HTML destinations open, you'll create 2 image files.
- if you call proc gpanel twice and have 2 HTML destinations open, you'll create 4 image files.
What is bothering you with this? Do you want successive proc gpanel calls to write to the same image?
If so, this is not how SAS graphics work.
What you can do though is use proc greplay to combine graphic outputs.
It will be painful though, because 1) EG makes it difficult by not showing catalog entries, and 2) ODS does not create a gseg catalog entries, so you must use SAS/GRAPH. Why so many dumb limitations I don't know, so be patient if you go this route.
There is a discussion here: https://communities.sas.com/t5/ODS-and-Base-Reporting/ODS-Graphics-and-proc-greplay/td-p/58932
Cynthia,
I agree with you that I did not explain the code properly. But Chris did answer my question. The reason why I have two ods HTML is because, the inner ods Html (id=4) generates graphs in separate ".htm file". While the outer ods html (id=3)creates all the graphs in one single ".html file". This helps save time by NOT using the sgpanel twice.
Hope you understood the reason why...
Thanks
To use proc greplay with SG procedure outputs:
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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: