| Return to SAS 9
|
This topic demonstrates several new features for PROC DOCUMENT in SAS 9.2.
The new BYGROUPS option on the LIST statement for PROC DOCUMENT lists any BY variables and values that are associated with the output objects that are stored in the document.
ods listing close;
proc sort data=sashelp.prdsal2 out=prdsal2;
by quarter prodtype;
run;
ods document name=sales(write);
proc tabulate data=prdsal2 f=dollar12.2;
by quarter prodtype;
class product;
var actual;
table product, actual;
run;
ods document close;
options nodate nonumber;
ods pdf file="bygroups.pdf";
ods listing;
proc document name=sales;
list/levels=all;
list/levels=all bygroups;
run;
quit;
ods pdf close;
ods listing close;
The new OBTEMPL statement outputs any external template that is associated with an output object, to active ODS destinations.
data a;
do a = 1 to 3;
do b = a * 10 to a*10+9;
output;
end;
end;
title;
ods document name=univ(write);
proc univariate data=a;
by a;
run;
ods document close;
options nodate nonumber;
ods pdf file="obtempl.pdf";
ods listing;
proc document name=univ;
list/levels=all bygroups;
obtempl \univariate\bygroup1\b\moments;
run;
quit;
ods pdf close;
ods listing;
Until SAS 9.2, replaying parts of a document had to be done by specifying the path of an output object or a folder. The only way to do conditional replays was to write somewhat complicated DATA step code and do a CALL EXECUTE to invoke another replay. Now you can use WHERE clauses in the replay statement to refine your selection of output objects.
The variables available to the WHERE clause include names (_name_), labels (_label_), type of object (_type_), path of the object (_path_), sequence number (_seqno_), dates (_cdate_, _ctime_, _cdatetime_, _mdate_, _mtime_, _mdatetime_), and probably the most powerful, BY variables.
/* Create a document with By groups */
ods listing close;
ods document name=docwhere(write);
proc sort data=sashelp.class out=work.class;
by age;
run;
proc means data=work.class;
by age;
var age height weight;
run;
ods document close;
/* Replay the objects when the By group 'age' is between 12 and 15 */
ods listing;
ods html file="docwhere.html";
proc document name=docwhere;
replay ^(where=(age > 12 and age < 15));
run;
ods html close;
In addition to the REPLAY statement, you can also use WHERE clauses on the COPY, MOVE, and LIST, and DELETE statements.