/*----------------------------------------------------------* This is the code of the macro that converts an ASCII text file to an RTF file as presented at PharmaSUG. This code is provided "AS IS" with no implied warrenty. In other words, use this code at your own risk. *----------------------------------------------------------*/ %macro txt2rtf(_txtfn= /*Text file to convert to RTF*/ ,_rtffn= /*RTF file that is to be output to*/ ,_pgwh=15840 /*Page width in twips*/ ,_pght=12240 /*Page height in twips*/ ,_mgns=1440 /*Margin width in twips*/ ,_lspe=%str(\landscape) /*If landscape, need to add this value*/ ,_fnsz=8 /*Font point size - integer*/ ); **************************; * 1440 twips = 1 inch ; * 567 twips = 1 cm ; **************************; data _null_; infile "&_txtfn" end=eof; length _txt $200; input; file "&_rtffn"; if _n_=1 then do; put '{\rtf1\ansi\ansicpg1252\deff0\deflang1033' / '{\fonttbl{\f0\fmodern\fprq1\fcharset0 Courier New;}}' / '{\colortbl \red0\green0\blue0;}' / "\paperw&_pgwh.\paperh&_pght.\margl&_mgns.\margr&_mgns." / "\margt&_mgns.\margb&_mgns.&_lspe." / "\viewkind4\uc1\pard\ql\fi0\li0\ri0\sb0\sa0\sl-%eval(&_fnsz*20)" / "\cf0\f0\fs%eval(&_fnsz*2) " _infile_; end; else do; if substr(_infile_,1,1)=byte(12) then do; _txt='\page '||substr(_infile_,2); put _txt; end; else if ^eof then put '\par ' _infile_; else if eof then put '\par ' _infile_ '}'; end; run; %mend txt2rtf;