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

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

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

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

View solution in original post

15 REPLIES 15
ballardw
Super User

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.

 

SASER
Fluorite | Level 6

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...

ChrisNZ
Tourmaline | Level 20

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.

SASER
Fluorite | Level 6

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

PGStats
Opal | Level 21

This can happen if you have two ODS destinations opened associated with the same graphic file type, such as the LISTING and HTML destinations. 

PG
SASER
Fluorite | Level 6

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?

ChrisNZ
Tourmaline | Level 20

@DSAS Please stop having us try to guess what your code looks like and giving piecemeal information.

 

As @ballardw suggested, you should share as much as you can in the first post. A good start would be your code. A sample data to run it doesn't hurt.

 

 

 

SASER
Fluorite | Level 6

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

 

Cynthia_sas
SAS Super FREQ

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

SASER
Fluorite | Level 6

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

ChrisNZ
Tourmaline | Level 20

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_sas
SAS Super FREQ
Hi:
I agree with Chris. I do not understand the nesting of your HTML files the way you are. It sounds like ODS HTML is doing exactly what you told it to do.

It makes more sense to me to have ONLY the HTML (ID=3) "sandwich" by itself for the NAME report/graph and then have ONLY the HTML(ID=4) for the BATCH report/graph. But, even so, your skeleton description of the code just doesn't make sense to me.

And, Chris is also correct that you have to decide how you want to create the graphs. To a certain extent SGPANEL and ODS make it unnecessary to need to use SAS/GRAPH and GREPLAY for a large portion of graphs. Since I still do not have a visual of what you mean by 1 graph per NAME or 1 graph per BATCH, I am still in the dark. 1 graph per NAME doesn't make sense, anyway -- would you only have 1 bar for each of your names?

Sending code for SASHELP.CARS, doesn't help. I want to see the SGPANEL code that you are using for your NAMES data and your BATCH data. I cannot imagine what your PANELBY variable is or what your VBAR or response variables are given that you said you will get 1 graph for every name.

Sorry, I just don't get it.

cynthia

SASER
Fluorite | Level 6

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

ChrisNZ
Tourmaline | Level 20

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
  • 15 replies
  • 2452 views
  • 2 likes
  • 5 in conversation