Making an RTF file Out of a Text File, With SAS Paper CC13

Similar documents
ABSTRACT INTRODUCTION THE PUT STATEMENT IS KEY THE ANATOMY OF THE DATA STEP TO PRODUCE THE REPORT

Utilizing SAS to Automate the Concatenation of Multiple Proc Report RTF Tables by Andrew Newcomer. Abstract

EXPORTING SAS OUTPUT ONTO THE WORLD WIDE WEB

Run your reports through that last loop to standardize the presentation attributes

ODS/RTF Pagination Revisit

Setting Up a Paper in APA Style Using Microsoft Word 2008 for MACs

Setting Up a Paper in APA Style Using Microsoft Word 2007

General Methods to Use Special Characters Dennis Gianneschi, Amgen Inc., Thousand Oaks, CA

Writing Programs in SAS Data I/O in SAS

A Mass Symphony: Directing the Program Logs, Lists, and Outputs

A Fully Automated Approach to Concatenate RTF outputs and Create TOC Zhiping Yan, Covance, Beijing, China Lugang Xie, Merck, Princeton, US

Pros and Cons of Interactive SAS Mode vs. Batch Mode Irina Walsh, ClinOps, LLC, San Francisco, CA

Post-Processing.LST files to get what you want

PDF Multi-Level Bookmarks via SAS

The EXPLODE Procedure

Oh Quartile, Where Art Thou? David Franklin, TheProgrammersCabin.com, Litchfield, NH

The correct bibliographic citation for this manual is as follows: SAS Institute Inc Proc EXPLODE. Cary, NC: SAS Institute Inc.

Demystifying Inherited Programs

9 Ways to Join Two Datasets David Franklin, Independent Consultant, New Hampshire, USA

Using SAS to Control the Post Processing of Microsoft Documents Nat Wooding, J. Sargeant Reynolds Community College, Richmond, VA

A SAS Macro Utility to Modify and Validate RTF Outputs for Regional Analyses Jagan Mohan Achi, PPD, Austin, TX Joshua N. Winters, PPD, Rochester, NY

Getting Up to Speed with PROC REPORT Kimberly LeBouton, K.J.L. Computing, Rossmoor, CA

Countdown of the Top 10 Ways to Merge Data David Franklin, Independent Consultant, Litchfield, NH

Black & White Graphic Novel Guide

Merging Data Eight Different Ways

Setting the Percentage in PROC TABULATE

Write SAS Code to Generate Another SAS Program A Dynamic Way to Get Your Data into SAS

Routing Output. Producing Output with SAS Software CHAPTER 6

How to Make Headers for APA, Section Breaks, Line Spacing, and Hanging Indents

The Professional Services Of Dojo Technology. Spreadsheet Files

Use the PCL Emul Menu to change printer settings that only affect jobs using the PCL emulation printer language.

AGAMA. Version 1.0 FONT ASSISTANT. for Windows 95/98 & NT. User's Guide

3. Formatting Documents

Creating Labels using Label Designer

DOCUMENTATION CHANGE NOTICE

Paper CC16. William E Benjamin Jr, Owl Computer Consultancy LLC, Phoenix, AZ

Regaining Some Control Over ODS RTF Pagination When Using Proc Report Gary E. Moore, Moore Computing Services, Inc., Little Rock, Arkansas

PharmaSUG China Paper 059

Corel Ventura 8 Introduction

Controlling SAS Datasets Using SAS System and Dataset Options (or I need to track the data!) David Franklin, New Hampshire, USA

Creating a Multi-line Plate

A Macro to Keep Titles and Footnotes in One Place

Standards User Guide. PowerSchool 6.0 Student Information System

The TRANTAB Procedure

Print My Cal. User Manual

Create a new document based on default template, other available template like: memo, fax, agenda.

The FORMS Procedure. Overview CHAPTER 20

Software License Agreement

AD07 A Tool to Automate TFL Bundling

Software License Agreement

Network Working Group Request for Comments: 1111 Obsoletes: 825 August 1989

Getting Started Manual Don t Get Caught With a File You Can t Open

Formatting Highly Detailed Reports: Eye-Friendly, Insight-Facilitating

A Tool to Compare Different Data Transfers Jun Wang, FMD K&L, Inc., Nanjing, China

Easy Match QC Lesson 9. Setting Up a Print Job

Software License Agreement

Smashwords Formatting Cheat-sheet

Printer Groups. System: Getting Started. Overview. Defining a printer group

Excel Level Three. You can also go the Format, Column, Width menu to enter the new width of the column.

Paper PO07. %RiTEN. Duong Tran, Independent Consultant, London, Great Britain

Reading in Data Directly from Microsoft Word Questionnaire Forms

Excel Tools Features... 1 Comments... 2 List Comments Formatting... 3 Center Across... 3 Hide Blank Rows... 3 Lists... 3 Sheet Links...

dbdos PRO 3 Quick Start Guide dbase, LLC 2014 All rights reserved.

An Introduction to PROC REPORT

Streamline Table Lookup by Embedding HASH in FCMP Qing Liu, Eli Lilly & Company, Shanghai, China

Step through Your DATA Step: Introducing the DATA Step Debugger in SAS Enterprise Guide

Flash Tutorial. Working With Text, Tween, Layers, Frames & Key Frames

The correct bibliographic citation for this manual is as follows: SAS Institute Inc Proc FORMS. Cary, NC: SAS Institute Inc.

USER TRAINING AND SUPPORT

A Visual Step-by-step Approach to Converting an RTF File to an Excel File

A Macro To Generate a Study Report Hany Aboutaleb, Biogen Idec, Cambridge, MA

Formatting an APA style Paper in Google Docs 1

And Now, Presenting... Turn the Tables on Boring Reports with SAS 9.2 and RTF Tagset Options Louise S. Hadden, Abt Associates Inc.

Informats. Informats Under UNIX. HEXw. informat. $HEXw. informat. Details CHAPTER 13

c122jan2714.notebook January 27, 2014

Programmer s Guide. Tally MT50 Emulation. PSi Drucker Family PP 80x

Macro Method to use Google Maps and SAS to Geocode a Location by Name or Address

ODS DOCUMENT, a practical example. Ruurd Bennink, OCS Consulting B.V., s-hertogenbosch, the Netherlands

How to Format Modern Language Association (MLA) Style Papers

The Newsletter will contain a Title for the newsletter, a regular border, columns, Page numbers, Header and Footer and two images.

LESSON 4. The DATA TYPE char

Color Graphic Novel Guide

IT S THE LINES PER PAGE THAT COUNTS Jonathan Squire, C2RA, Cambridge, MA Johnny Tai, Comsys, Portage, MI

LST in Comparison Sanket Kale, Parexel International Inc., Durham, NC Sajin Johnny, Parexel International Inc., Durham, NC

PharmaSUG Paper TT10 Creating a Customized Graph for Adverse Event Incidence and Duration Sanjiv Ramalingam, Octagon Research Solutions Inc.

Adobe FrameMaker to Microsoft Word Document Conversion Part 4: Landscape Tables and Figures

Housing Society Module

Automating Comparison of Multiple Datasets Sandeep Kottam, Remx IT, King of Prussia, PA

SAS Macro Dynamics: from Simple Basics to Powerful Invocations Rick Andrews, Office of Research, Development, and Information, Baltimore, MD

PROBLEM FORMULATION, PROPOSED METHOD AND DETAILED DESCRIPTION

Functions vs. Macros: A Comparison and Summary

Java Style Guide. 1.0 General. 2.0 Visual Layout. Dr Caffeine

FILE TYPES & SIZES BOOK COVER

Multi-line PCB Text Support

Microsoft Word 2007 Lesson 1

Microsoft Word 2007 Final Lesson

Unit 2 Fine-tuning Spreadsheets, Functions (AutoSum)

Data Presentation ABSTRACT

Using MACRO and SAS/GRAPH to Efficiently Assess Distributions. Paul Walker, Capital One

SUGI 29 Posters. Paper A Group Scatter Plot with Clustering Xiaoli Hu, Wyeth Consumer Healthcare., Madison, NJ

Transcription:

Making an RTF file Out of a Text File, With SAS Paper CC13 David Franklin Independent SAS Consultant While you are waiting, some trivia. Q is the only letter in the alphabet that does not appear in the name of any state of the United States.

Introduction Motivation: a simple tool that would convert a ASCII Text output to RTF, regardless of where SAS is run Paper looks at a SAS macro that converts output generated in ASCII Text format and converts it into a RTF format file, inside a single datastep Most in-house tools either use a VBA, VB Script or a SAS macro that uses ODS RTF to read in the text file and convert it to an RTF (or MS Word file) A SAS macro that takes an ASCII generated text file, adds a wrapper around the text and the output is RTF RTF can be read in MS Word, OpenOffice, WordPerfect, Lotus Symphony, etc.

What is RTF? Example of RTF, Hello World: {\rtf1\ansi\ansicpg1252\deff0\deflang1033 {\fonttbl{\f0\fmodern\fprq1\fcharset0 Courier New;}} \viewkind4\uc1\pard\f0\fs20 Hello World!\par } This text does look daunting, but the text up to the point of the "Hello World!" is just the header text which contains the signal that it is an RTF file, ASCII format, code page and language information, the font that is being used, and the font size. The '\par' is in effect a carriage return, and the final '}' closes the file.

The Macro I What parameters should be in the macro: paper size and orientation margin size font size line height There should be two more the location and name of the input and output files

The Macro I What parameters should be in the macro: paper size and orientation margin size font size line height There should be two more the location and name of the input and output files 01 %macro txt2rtf(_txtfn= /*Text file to convert to RTF*/ 02,_rtffn= /*Output RTF file name*/ 03,_pgwh=15840 /*Page width in twips*/ 04,_pght=12240 /*Page height in twips*/ 05,_mgns=1440 /*Margin width in twips*/ 06,_lspe=%str(\landscape) /*If landscape, add this value*/ 07,_fnsz=8 /*Font point size - integer*/ 08 ); Important conversion: 1440twips=1in and 567twips=1cm

The Macro II 09 data _null_; 10 infile "&_txtfn" end=eof; 11 length _txt $200; input; 12 file "&_rtffn"; 13 if _n_=1 then do; 14 put '{\rtf1\ansi\ansicpg1252\deff0\deflang1033 ' / 15 '{\fonttbl{\f0\fmodern\fprq1\fcharset0 ' / 16 'Courier New;}}{\colortbl \red0\green0\blue0;}' / 17 "\paperw&_pgwh.\paperh&_pght.\margl&_mgns." / 18 "\margr&_mgns."\margt&_mgns.\margb&_mgns.&_lspe." / 19 "\viewkind4\uc1\pard\ql\fi0\li0\ri0\sb0\sa0" / 20 "\sl-%eval(&_fnsz*20)\cf0\f0\fs%eval(&_fnsz*2) " 21 _infile_; end; 22 else do; 23 if substr(_infile_,1,1)=byte(12) then do; 24 _txt='\page ' substr(_infile_,2); 25 put _txt; end; 26 else if ^eof then put '\par ' _infile_; 27 else if eof then put '\par ' _infile_ '}'; end; 28 run; %mend;

Page and Linesize Settings The hardest part when setting up the macro is the settings to use when setting up your text output linesize and pagesize settings. As a guide, refer to the following table (margin size is set to 1 inch and Courier New font is used): Paper Size Font Size PAGESIZE LINESIZE ----------------------------------------- LETTER 8 58 134 LETTER 9 52 119 LETTER 10 46 104 A4 8 49 145 A4 9 44 129 A4 10 39 116 If other margin or font sizes or fonts are needed then attempt to get the pagesize and linesize values within your word processor by finding the maximum number of characters per line and per page it is possible to fill.

Enhancements One version replaced the _pght and _pgwh parameters with page sizes, e.g. values such as A4 and LETTER. Another enhancement was to allow for half point sizes, e.g. 8.5, but the gains from this were minimal and added an extra step where the calculation for the line spacing and font size had to be done before the step that actually did the conversion. A recent enhancement was one where it had to handle situations where the file was an old IBM style file which contained control characters in the first column, e.g. 1 for page break and 0 for a blank line.

Questions and Contact Information Questions? Contact Information David Franklin Independent SAS Consultant 16 Roberts Road, Litchfield, NH 03052 Phone: 603-275-6809 Email: dfranklinuk@compuserve.com Web: http://www.theprogrammerscabin.com LinkedIn: http://www.linkedin.com/in/davidfranklinnh

Acknowledgement SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies.