Hi:
I had problems getting the Graphics Template Language to work properly, so I created a new variable for the one-to-one line coordinates and added plotted it by adding a "series" statement to the SGPLOT and SGPANEL Procs. It works perfectly. The program is shown below. For now I've given up trying to get one-to-one lines on the PROC SGSCATTER / Matrix output.
------------------------------
ODS LISTING CLOSE;
GOPTIONS RESET=ALL ftext='Helvetica' ;
OPTIONS orientation=landscape papersize=letter nonumber nodate;
ODS graphics on/reset
border = off
height = 7.5in
width = 9in
;
ODS PDF file='c:\temp\pm_intercomparison_hourly_data.pdf' DPI=300 style=analysis;
TITLE1 'CAPMoN PM Intercomparison Study--Hourly' j=r h=.8 "&SYSDATE9";
TITLE2 ;
* Calculate the min/max of all observations (ignoring the BY variable) for each of the two plotting variables;
PROC MEANS DATA=alldata NOPRINT;
VAR egbbam1 egbbam2;
OUTPUT OUT=min_max(KEEP=min_var1 min_var2 max_var1 max_var2) min=min_var1 min_var2 max=max_var1 max_var2;
RUN;
* Create new variables to store the MIN and MAX values of the two variables.
Insert the MIN pairing on the first observation of the BY group, and the MAX pairing in the last observation of the BY group.;
DATA alldata_with_1_to_1;
SET alldata;
BY yr_month;
RETAIN one 1 _found 0;
IF FIRST.yr_month
THEN DO;
SET min_max POINT=one;
one_to_one_x = MIN(min_var1,min_var2);
one_to_one_y = one_to_one_x;
END;
IF LAST.yr_month
THEN DO;
SET min_max POINT=one;
one_to_one_x = MAX(max_var1,max_var2);
one_to_one_y = one_to_one_x;
END;
* Store the value of the first non-missing BY group variable in the macro variable first_by_variable_value;
IF yr_month NE ''
AND NOT _found
THEN DO;
CALL SYMPUTX('first_by_variable_value',yr_month);
_found = 1;
END;
LABEL one_to_one_y = '1-1 Line';
DROP min_var1 min_var2 max_var1 max_var2 _found;
RUN;
* For SGPLOT output where all BY groups are on one plot, include the one-to-one pairings only for the first BY group.;
DATA alldata_for_sgplot;
SET alldata_with_minmax;
IF yr_month NE "&first_by_variable_value"
THEN DO;
one_to_one_x = .;
one_to_one_y = .;
END;
RUN;
PROC SGPLOT DATA=alldata_for_sgplot;
series x=one_to_one_x y=one_to_one_y / lineattrs=(pattern=dot thickness=2px color=gray) ;
REG x=egbbam1 Y=egbbam2 / CLM GROUP=yr_month;
RUN;
QUIT;
PROC SGPANEL DATA=alldata_with_1_to_1;
PANELBY yr_month / columns=4 rows=4 uniscale=all ;
reg x=egbbam1 Y=egbbam2 ;
series x=one_to_one_x y=one_to_one_y / lineattrs=(pattern=dot thickness=2px color=gray) ;
RUN;
QUIT;
ODS PDF CLOSE;
ODS GRAPHICS OFF;
... View more