QUERIES BY ODS BEGINNERS Varsha C. Shah, Dept. of Biostatistics, UNC-CH, Chapel Hill, NC ABSTRACT This paper presents a list of questions often asked by those initially experimenting with ODS output. Why might questions arise? One could be converting from Version 6 or simply trying to improve the appearance of output. Also, often the same results can be achieved in several different ways, and a novice might wonder about this. Here, an attempt is made to answer some common questions in as simple a way as possible, one thing at a time. It is assumed that after getting to know the basics, the reader will experiment with combinations of ODS features to achieve the desired output appearance. To keep things simple, neither templates nor ODS styles are introduced. Also, it is worth mentioning that future versions of SAS will make some of the features described here available more conveniently. This work was done with Version 8.2. INTRODUCTION ODS is full of surprises. It creates what was not possible with simple listings, but some additional things come along which the programmer may want to deal with. The illustrations are based on randomly generated data. The discussion is limited to two procedures commonly used when attractive output is desired, namely PROC REPORT and PROC TABULATE. Most of the features are common to both procedures. The SAS program and results are included in the appendix. The options or statements required for the desired changes in the output are highlighted in light gray. Each affected statement is followed by a dark square indicating the question numbers addressed, from the following list of commonly recurring questions at my organization: Q1 How can I change the fonts of titles and footnotes? Q2 How can I get rid of shading in PROC TABULATE output? Q3 How can I get rid of shading in PROC REPORT output? Q4 How can I change column width in PROC TABULATE output? Q5 How can I change column width in PROC REPORT output? Q6 How can I align text or numbers in columns? Q7 How can I change page numbers to start with a number greater than 1? Q8 In RTF output, how can I format characters as subscripts or superscripts? Q9 In RTF output, how can I add spaces in formats for indentation or other purposes? Q10 How can I create a blank line between two footnotes? SOME CAUTIONS Some of the solutions need further explanation. Here they are addressed by question number. Q10: If a blank line has to be left between two footnotes, a blank footnote should be created as illustrated in the example for the superscript/subscript(q8) and indentation(q9). Q4 & Q5: Whenever a CELLWIDTH value is specified, it should be followed by a measurement unit such as cm or in. files. ODS by default assigns page number 1 at the beginning of a file, whereas you do not want the page number to be reset to 1 for the entirety of the collection. The way to get around this depends on the type of file being created. For an RTF file you need a macro that can be obtained from the SAS Institute website. For a PDF file the desired page number should be included in an OPTIONS statement preceding the procedure call. The illustration shows a PDF file starting with page number 5. Q9: In traditional SAS output, it is possible to specify leading blanks in formats and have them respected. However, ODS will ignore multiple leading blanks in applying formats, thus making it impossible to have indentation by normal means. It also collapses multiple consecutive intermediate spaces into one. However, spaces can be maintained in RTF output, with some caveats. The irregular spacing in the final illustration is intentional for displaying relevant concepts. In the format for region, some RTF language coding is used to achieve desired spacing. By placing the text within curly braces {}, one leading blank can be achieved by simply using one leading space. The symbol {\line} results in going to the next line, and use of multiple \~ within curly braces can be used to produce multiple blank spaces. Here, the leading blank between the curly braces for value 01 has produced one space before North Carolina in the first data row of the output. For value 02, the leading blank before Piedmont and the \~ preceding North Carolina have accomplished the same result of skipping one space. The format for value 03 yields interesting results. The nine blank symbols (\~) preceding Mountain do indent the word in the next line. But the way it aligns under the word Tennessee, it seems to have skipped only four spaces rather than nine. This illusion is related to use of proportional fonts. Basically, one needs to experiment until satisfactory results are achieved. CONCLUSION ODS is a powerful tool, but there are many hidden assumptions in creating the destination files. It is possible to modify the default appearance of the output by employing overriding statements and options. Once one has become comfortable with some basic ODS possibilities, one can produce very pleasant output. REFERENCES Haworth, Lauren E., Output Delivery System: The Basics, Cary, NC: SAS Institute Inc., 2001. SAS Institute Inc., The Complete Guide to the SAS Output Delivery System, Version 8, Cary, NC: SAS Institute Inc., 1999. ACKNOWLEDGEMENTS The author wishes to thank the Collaborative Studies Coordinating Center statisticians and programmers for their queries that led to the compilation of the basic questions. The author would like to thank Guochen Song for his help in resolving some of the questions and finding the answers. The work would not have been possible without the support and encouragement of my supervisor Kathy Roggenkamp.. Q7: There may be times when you want to compile a collection of reports from several tables written to different RTF or PDF
CONTACT INFORMATION Varsha C. Shah CSCC, Department of Biostatistics, CB #8030 University of North Carolina Chapel Hill, NC 27514 Phone: 919-966-5160 Fax: 919-966-6335 Email: uccvcs@mail.cscc.unc.edu APPENDIX proc format; value $region '01'="North Carolina Coastal" '02'="North Carolina Piedmont" '03'="Tennessee Mountain" ; value $trtfmt 'T1'="Treatment1" 'T2'="Treatment2" 'T3'="Treatment3" ; options nocenter missing=' '; *************************************************************************************************************; ************************************************ proc report************************************************; *************************************************************************************************************; *-x-x-x-x-x-x- generate the output unadjusted report -x-x-x-x-x-x-*; ods rtf file="&odsoutdir\&job._unadj_report.rtf"; title1 "Proc Report results unadjusted"; proc report data=example1 split='~' nowindows; column region trtment,(ntot avg stdev); define trtment /across order=internal " "; define region /group "REGION" order=internal; define ntot /analysis " N " ; define avg /display "Mean" mean; quit; define stdev /display "STD" mean; Proc Report results unadjusted T1 T2 T3 REGION N Mean STD N Mean STD N Mean STD 01 4 11.25 7.5443135 3 8 3.6055513 3 10.333333 4.163332 02 4 10.75 4.0311289 4 12.75 7.6321688 4 7.5 5.0662281 03 5 10.4 5.2249402 5 9.8 3.8987177 5 11.4 2.4083189 *-x-x-x-x-x-x- generate the output adjusted for shading, column width,alignment -x-x-x-x-x-x-*; ods rtf file="&odsoutdir\&job._adj_report.rtf"; options pageno=5; *Illustrates does not work with RTF file;
Title1 "Proc Report results adjusted for shading, column width, alignment"; proc report data=example1 split='~' nowindows; column region trtment,(ntot avg stdev); define trtment /across format=$trtfmt. style=[background=white ] order=internal " "; *Q3; define region /group format=$region style=[background=white cellwidth=3.7 cm] "REGION" order=internal; *Q3,Q5; define ntot /analysis format=f2.0 center style=[background=white cellwidth=1 cm] quit; define avg " n " ; *Q3,Q5,Q6; /display format=f6.3 style=[background=white cellwidth=1.2 cm] "mean" mean; *Q3,Q5,Q6; define stdev /display format=f6.4 style=[background=white cellwidth=1.2 cm] "STD" mean; *Q3,Q5,Q6; Proc Report results adjusted for shading, column width, alignment Treatment1 Treatment2 Treatment3 REGION N Mean STD N Mean STD N Mean STD North Carolina Coastal 4 11.250 7.5443 3 8.000 3.6056 3 10.333 4.1633 North Carolina Piedmont 4 10.750 4.0311 4 12.750 7.6322 4 7.500 5.0662 Tennessee Mountain 5 10.400 5.2249 5 9.800 3.8987 5 11.400 2.4083 x-x-x-x-x-x- generate the output adjusted for page numbers. -x-x-x-x-x-x-; ods pdf file="&odsoutdir\&job..pdf"; *Q7; options pageno=5; *Q7; Title1 "Proc Report results adjusted for page numbers- pdf file"; proc report data=example1 split='~' nowindows; column region trtment,(ntot avg stdev); define trtment /across format=$trtfmt. style=[background=white ] order=internal " "; define region /group format=$region. style=[background=white cellwidth=3.7 cm] "REGION" order=internal; define ntot /analysis format=f2.0 center style=[background=white cellwidth=1 cm] define avg quit; ods pdf close; *Q7; " n " ; /display format=f6.3 style=[background=white cellwidth=1.3 cm] "mean" mean; define stdev /display format=f6.4 style=[background=white cellwidth=1.3 cm] "STD" mean;
*************************************************************************************************************; ***********************************************proc tabulate***********************************************; *************************************************************************************************************; proc format; value $region '01'="North Carolina Coastal" '02'="North Carolina Piedmont" '03'="Tennessee Mountain(1)" ; **** Fotnotes created for the illustration ***; data _null_; length text1 text2 $65 text3 $180 add_txt1 add_txt2 $210; text1="this footnote is purposely made long for the illustration purposes."; text2="so the two sentences are concatenated. "; text3=left(trim(text1)) ' ' left(trim(text2)); text4="the illustration created by VCS"; text5="illustrate partial font modification"; call symput ("text3",text3); call symput ("text4",text4); call symput ("text5",text5); footnote1 "(1)Includes some bordering counties of North Carolina"; footnote2 "&text3"; footnote3 "&text4"; footnote4 "&text5"; *-x-x-x-x-x-x- generate the output unadjusted - tabulate-x-x-x-x-x-x-*; options nocenter missing=' ' ps=30; ods rtf file="&odsoutdir\&job._unadj_tabulate.rtf"; Title1 "Proc Tabulate results unadjusted"; proc tabulate data=example2 format=20.; CLASS region trtment ; CLASSLEV region trtment ; FORMAT region $region.; VAR n avg std ; TABLE region=' ', trtment=' ' * (n='n' *sum=' ' avg='%' *sum=' '
std ='std' *sum=' ' ) /PRINTMISS MISSTEXT = ' N/A ' RTS=27 BOX =[label="{region}"] ; Proc Tabulate results unadjusted REGION T1 T2 T3 N % STD N % STD N % STD North Carolina Coastal 4 11 8 3 8 4 3 10 4 North Carolina Piedmont 4 11 4 4 13 8 4 8 5 Tennessee Mountain(1) 5 10 5 5 10 4 5 11 2 (1)Includes some bordering counties of North Carolina This footnote is purposely made long for the illustration purpose So the two sentences are concatenated a as text is added. The illustration created by VCS Illustrate partial font modification -x-x-x-x-x-x- generate the output modified for fontsizes, shade, -x-x-x-x-x-x-*; *-x-x-x-x-x-x-cellwidth, and superscripts/subscripts. -x-x-x-x-x-x-*; proc format; value $region '01'="{North Carolina Coastal}" '02'="{North Carolina Piedmont}" '03'="{Tennessee Mountain}{\super(1)\nosupersub}"; *Q8; footnote1 "{\super(1)\nosupersub}{includes some bording counties of North Carolina}"; *Q8; footnote2 height=10pt italic "&text3"; *Q1; footnote3 height=10pt italic "&text4"; *Q1; footnote4 " "; *Creating a blank line between the footnotes; footnote6 height=12pt font='arial' "want only " bold "partial " font='arial' height=12pt "modification"; *Q1; ods rtf file="&odsoutdir\&job._adj_tabulate.rtf"; Title1 "Proc Tabulate results adjusted for shading, fontsize, cellwidth, super/subscripts"; proc tabulate data=example2 missing style=[background=white] format=20.; CLASS region trtment ; CLASSLEV trtment/style=[background=white] ; *Q2; CLASSLEV region /style=[cellwidth=3 cm background=white] ; *Q4,Q2; VAR n avg std /style=[cellwidth=1.0 cm background=white];*q4,q2; FORMAT region $region.;
TABLE region=' ', trtment=' ' * (n='n' *sum=' '*f=2.0 avg='%' *sum=' '*f=4.1 std ='std' *sum=' ' * f=4.2 ) /PRINTMISS MISSTEXT = ' N/A ' RTS=27 BOX =[label="{region}" style=[background=white]] ; *Q2; Proc Tabulate results adjusted for shading, fontsize, cellwidth, super/subscripts REGION T1 T2 T3 N % STD N % STD N % STD North Carolina Coastal 4 11.3 7.54 3 8.0 3.61 3 10.3 4.16 North Carolina Piedmont 4 10.8 4.03 4 12.8 7.63 4 7.5 5.07 Tennessee Mountain (1) 5 10.4 5.22 5 9.8 3.90 5 11.4 2.41 (1) Includes some bordering counties of North Carolina This footnote is purposely made long for the illustration purpose So the two sentences are concatenated as well as text is added. The illustration created by VCS *Q10;; Blank line created by footnote4 Want only partial font modification *-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-*; * generate the output modified for indentation,leading spaces *; *-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-*; ods rtf file="&odsoutdir\&job._adjindent_tabulate.rtf"; proc format; value $region '01'="{ North Carolina}{\line}{Coastal}" '02'="{\~North Carolina}{\line}{ Piedmont}" '03'="{Tennessee}{\line}{\~\~\~\~\~\~\~\~\~Mountain}{\super(1)\nosupersub}"; *Q9,Q8,; Title1 "Proc Tabulate results adjusted for indentation"; proc tabulate data=example2 missing style=[background=white] format=20.; CLASS region trtment ; CLASSLEV trtment/style=[background=white] ; CLASSLEV region /style=[cellwidth=3 cm background=white] ; VAR n avg std /style=[cellwidth=1.0 cm background=white] ; FORMAT region $region.; TABLE region=' ',
trtment=' ' * (n='n' *sum=' '*f=2.0 avg='%' *sum=' '*f=4.1 std ='std' *sum=' ' * f=4.2 ) /PRINTMISS MISSTEXT = ' N/A ' RTS=27 BOX =[label="{region}" style=[background=white]] ; Proc Tabulate results adjusted for indentation REGION T1 T2 T3 N % STD N % STD N % STD North Carolina Coastal 4 11.3 7.54 3 8.0 3.61 3 10.3 4.16 North Carolina Piedmont 4 10.8 4.03 4 12.8 7.63 4 7.5 5.07 Tennessee Mountain (1) 5 10.4 5.22 5 9.8 3.90 5 11.4 2.41 (1) Includes some bordering counties of North Carolina This footnote is purposely made long for the illustration purpose So the two sentences are concatenated as well as text is added. The illustration created by VCS *Q10;; Blank line created by footnote4 Want only partial font modification