---A macro that allows you to easily create RTF files from your dataset
rtfCreator is a simple SAS macro that enables you to generate RTF tables by specifying:
- Dataset name
- Number of columns
- Variable names
- Column justifications (Left / Right / Center)
- Column widths
Optionally, you can apply your own STYLE template or add extra formatting like headers, footers, page breaks, and bottom borders.
0.0.1(9July2025) : Initial version
0.0.2(13Jun2026) : bug fix in refdefine. Parameter: LAYOUT Default Value=(Null) to PORTRAIT.
| Parameter | Required | Description |
|---|---|---|
DS |
Y | Name of the input dataset |
COLNUM |
Y | Number of columns |
VARLST |
Y | List of variable names |
JUSTLST |
Y | List of justifications (Left, Right, etc.) |
WIDTHLST |
Y | List of column widths |
OUTFILE |
N | Output file name |
PAGEVAR |
N | Variable flag for page breaks |
LINEVAR |
N | Variable flag for bottom borders |
TBLHEAD |
N | Header text to appear at top of the table |
TBLFOOT |
N | Footer text to appear at bottom of the table |
STYLENAM |
N | RTF style template name |
%rtfcreator(DS=sashelp.class
,COLNUM =2
,VARLST =name sex
,JUSTLST =Left Center
,WIDTHLST=300 150
);%rtfcreator(DS=sashelp.class
,COLNUM =2
,VARLST =name sex
,JUSTLST =Left Center
,WIDTHLST=300 150
,STYLENAM=Journal
);%rtfCreator(DS=sashelp.class
,COLNUM =2
,VARLST =name sex
,JUSTLST =Left Center
,WIDTHLST=300 150
,TBLHEAD=%str(Table Head)
,TBLFOOT=%str(Table Foot)
);data RTFDS1;
set sashelp.class;
if _n_ eq 7 then PAGEBRK=1;
run;
%rtfcreator(DS=RTFDS1
,COLNUM =2
,VARLST =name sex
,JUSTLST =Left Center
,WIDTHLST=300 150
,PAGEVAR=PAGEBRK
);Example E -- adding a bottom border (you need to create a bottom border flag variable in advance, e.g., XXX = 1).;
data RTFDS2;
set sashelp.class;
if _n_ eq 7 then BLINE=1;
run;
%rtfcreator(DS=RTFDS2
,COLNUM =2
,VARLST =name sex
,JUSTLST =Left Center
,WIDTHLST=300 150
,LINEVAR=BLINE
);PharmaForest is a repository of SAS packages. These packages are built on top of SAS Packages framework(SPF), which was developed by Bartosz Jablonski.
For more information about SAS Packages framework, see SAS_PACKAGES.
You can also find more SAS Packages(SASPACs) in SASPAC.
Firstly, create directory for your packages and assign a fileref to it.
filename packages "\path\to\your\packages";Secondly, enable the SAS Packages Framework.
(If you don't have SAS Packages Framework installed, follow the instruction in SPF documentation to install SAS Packages Framework.)
%include packages(SPFinit.sas)Install SAS package you want to use using %installPackage() in SPFinit.sas.
%installPackage(packagename, sourcePath=\github\path\for\packagename)(e.g. %installPackage(ABC, sourcePath=https://github.com/XXXXX/ABC/raw/main/))
Load SAS package you want to use using %loadPackage() in SPFinit.sas.
%loadPackage(packagename)




