Hi:
I'm not sure what you mean by "isNewWindow" -- if you are using SAS/GRAPH GPLOT, then most of the devices that you use (GIF, JPEG, PNG, etc) will build a static image file that is stored in a special SAS catalog. So the theory that there is a new "window" variable that you can somehow test or set or change is not a theory that applies to how SAS/GRAPH operates.
SAS/GRAPH will display every image created in the GRAPH1 window until all the images that you created in your step have been displayed. However, your SAS/GRAPH job is not writing to that "window" directly -- the image is created first and then the finished image is displayed.
PROC GPLOT has the OVERLAY option. The SGPLOT procedure has overlay capabilities also. However -- think of 1 procedure step as producing 1 image (unless you have a BY statement or RUN group processing in your code). The only way you generate a new "image" in the GRAPH1 window or in your output is to explicitly provide a data situation (such as a new BY group) or a new action statement (such as a new PLOT statement after a RUN;) or end one step and start another procedure step that produces an image.
Also remember that your macro program will only generate code that gets any macro variable references resolved -- and then the resolved code will be sent forward to the compiler for checking and then the checked code will go forward to be executed. The macro program, itself, is not causing any images to be built -- it is only generating resolved code statements. If your macro program contains a PROC GPLOT statement, then the first invocation of the macro program would generate 1 image; the second invocation of the macro program would cause a second PROC GPLOT statement to be sent to the compiler and this second PROC GPLOT statement would act as a step boundary to the first GPLOT statement. So depending on the code you want to generate, you may want to write your macro program differently. Or, using the technique below, you may find that you do not need a macro program at all.
PROC GPLOT in particular has a second method to display many different lines on a single plot. This version of the PLOT statement would be:
[pre]
plot y*x=z;
OR
plot faren*month=city;
[/pre]
as shown in this sample program in the documentation:
http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#gplvrbl2-ex.htm
which shows temperature by city. In the sample program, there are only 3 cities, but if you used this technique, instead of the overlay technique, GPLOT would draw a separate line for each "Z" variable --or for each city, as shown in the sample.
You may be able to combine the above technique with BY group processing to generate a new multi-line plot for a group of observations, depending on your data. If you do a PROC PRINT for the sample program's data and compare that structure to your data structure, you should be able to figure out whether your data are in the right structure for using this particular GPLOT method. The program below illustrates an example of RUN group processing (where each RUN group produces 1 plot) versus using the alternate PLOT technique versus using the alternate technique with a BY statement.
cynthia
[pre]
** summarize data;
proc means data=sashelp.prdsale nway;
class country product month;
var actual;
output out=work.sum sum=actsum;
run;
ods listing;
proc print data=work.sum;
run;
** Show Multiple RUN groups, each for a different;
** product within one country;
symbol i=join v=dot;
proc gplot data=work.sum;
where product='DESK' and country='CANADA';
title '1a) DESK/CANADA';
plot actsum*month;
run;
where product='CHAIR' and country='CANADA';
title '1b CHAIR/CANADA';
plot actsum*month;
run;
quit;
** Show the alternate plot technique with a different;
** RUN group for different countries;
symbol i=join v=dot;
proc gplot data=work.sum;
where country='CANADA' ;
title '2a) CANADA - Alternate PLOT technique';
plot actsum*month=product;
run;
where country='GERMANY' ;
title '2b) GERMANY - alternate PLOT technique';
plot actsum*month=product;
run;
quit;
** show the use of the BY statement with the alternate;
** plot technique;
symbol i=join v=dot;
proc gplot data=work.sum;
by country;
title '3) Using a BY statement';
plot actsum*month=product;
run;
quit;
[/pre]