Skip to content

PharmaForest/rtfcreator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rtfCreator

A macro that allows you to easily create RTF files from your dataset

pharmaforest

---

Overview

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.


Version history

0.0.1(9July2025) : Initial version

0.0.2(13Jun2026) : bug fix in refdefine. Parameter: LAYOUT Default Value=(Null) to PORTRAIT.


Parameters

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

How to Use

Example A -- Simply Table;

%rtfcreator(DS=sashelp.class
,COLNUM  =2
,VARLST  =name sex 
,JUSTLST =Left Center
,WIDTHLST=300 150 
);

image


Example B -- use your STYLE template. (e.g. Journal);

%rtfcreator(DS=sashelp.class
,COLNUM  =2
,VARLST  =name sex 
,JUSTLST =Left Center
,WIDTHLST=300 150 
,STYLENAM=Journal
);

image


Example C -- Add text outside the table, bottom or top;

%rtfCreator(DS=sashelp.class
,COLNUM  =2
,VARLST  =name sex 
,JUSTLST =Left Center
,WIDTHLST=300 150 
,TBLHEAD=%str(Table Head)
,TBLFOOT=%str(Table Foot)
);

image


Example D -- Page break (you need to create a page break flag variable in advance, e.g., XXX = 1).;

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
);

image


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
);

image

What is SAS Packages?

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.

How to use SAS Packages? (quick start)

1. Set-up SPF(SAS Packages Framework)

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)

2. Install SAS package

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/))

3. Load SAS package

Load SAS package you want to use using %loadPackage() in SPFinit.sas.

%loadPackage(packagename)

Enjoy😁

About

mirror of rtfcreator

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages