Per @PaigeMiller , I wrote a macro to do this:
/* Place graphs in work directory so deleted. */
ods listing gpath="%sysfunc(getoption(work))";
*Closes html results;
ods html close;
*DM Submits a SAS statement to the Program Editor, Log, or Procedure Output;
dm log "OUT; CLEAR; LOG; CLEAR;" log continue;
dm log 'next results; clear; cancel;' whostedit continue;
*Creates a new html result;
ods html newfile=none;
DATA test;
INPUT id group_one $ group_two $ results _lsl_ _usl_;
DATALINES;
1 A A 1 2 4
2 A A 2 2 4
3 A A 3 2 4
4 A A 4 2 4
5 A A 5 2 4
6 B B 6 5 7
7 B B 7 5 7
8 B B 8 5 7
9 B B 9 5 7
10 B B 10 5 7
;
RUN;
DATA test;
SET test;
concat_columns = compress(cat(group_one, "_", group_two));
RUN;
PROC SQL NOPRINT;
SELECT DISTINCT quote(trim(concat_columns))
INTO :concat_filter SEPARATED BY "~"
FROM test
;
QUIT;
%MACRO loop_charts();
%LET filter_length = %sysfunc(countw(&concat_filter,%str(~),mq));;
%DO i=1 %TO &filter_length;
%LET cur_cond = %scan(&concat_filter, &i, "~");
/* Create subset... */
PROC SQL;
CREATE TABLE test_subset AS
SELECT *
FROM test
WHERE concat_columns IN ("&cur_cond")
;
QUIT;
/* Grab USL & LSL */
DATA null;
SET test_subset END=LAST;
IF LAST THEN DO;
call symput("lsl_mac", _lsl_);
call symput("usl_mac", _usl_);
END;
RUN;
%PUT --> Lower Spec Limit &lsl_mac;
PROC SHEWHART DATA=test_subset;
IRCHART results*id /
lsl=&lsl_mac
usl=&usl_mac;
inset lsl="Lower Spec" usl="Upper Spec" cp(6.4)/
position=rm
cshadow=black
header="Summary Stats";
RUN;
%END;
%MEND loop_charts;
%loop_charts();
... View more