I used the following code to generate a table,
proc report data=final nowd headline headskip split='^' missing wrap spacing=1;
column (treatment patient_id visit dose rsdtc rsdy assessor1-assessor5 adjudicator best_overall);
define treatment /"Treatment" order group width=10 left flow spacing=1;
define patient_id /"Patient^Number" order group width=8 center spacing=1;
define visit /"Visit" group order=data width=7 left spacing=1 ;
define dose /"Assigned^Dose" group width=8 spacing=1;
define rsdtc /"Assessment^Date" order group width=10 left spacing=1;
define rsdy /"Relative^Study^Day*" order group width=8 left spacing=1 ;
define assessor1 /"Assessor1" width=9 center spacing=1;
define assessor2 /"Assessor2" width=9 center spacing=1;
define assessor3 /"Assessor3" width=9 center spacing=1 ;
define assessor4 /"Assessor4" width=9 center spacing=1;
define assessor5 /"Assessor5" width=9 center spacing=1;
define Adjudicator /"Adjudicator**" width=13 center spacing=1 ;
define best_overall /"Best^Overall^Response" width=8 center ;
But got misalignment issues in both column labels and column data. Can anyone help? Thanks
Hi, PROC PRINTTO is NOT making an RTF file. You are making an ASCII text file that you are opening with Microsoft Word.
A true RTF file is created with ODS RTF. You do not have ODS RTF statements in the code you show here. If you open a true ODS RTF file with Notepad, you see RTF control strings at the top of the file, as shown if I run this code and then open the resulting RTF file with Notepad:
ods rtf file='c:\temp\class.rtf';
proc print data=sashelp.class;
run;
ods rtf close;
as opposed to using PROC PRINTTO like this:
proc printto print='c:\temp\classreport.txt'; run;
proc print data=sashelp.class;
run;
proc printto; run;
You can compare the 2 outputs by opening each file with Notepad.
ODS RTF file opened with Notepad:
PROC PRINTTO file opened with Notepad:
If you actually used ODS RTF, then the file would be rendered correctly whether you were using Word 97, Word 2000 or Word 2013. ODS RTF has been using RTF control syntax ever since Word 97. When you make an ASCII text file with PROC PRINTTO and then open the text file with Word, you generally have to adjust the orientation and the font for the entire document to have the output look as it does in the LISTING window.
cynthia
I am generating a rtf file (a listing). When I opened it with Word, the alignment is strange.
Now I choose "File' -- 'Options' -- "Advanced" -- bottom shows word 97 format; after I changed to word 2010 for the "layout the document as if created in word 2010", the alignment is perfect. it seems SAS default output rtf is word 97 version.
Is there a way to set the word version 2010 once for all? It seems I have to re-set it in each .rtf file.
options formchar="|----|+|---+=|-/<>" pageno=1 nonumber nocenter nodate ps=46 ls=134 nobyline ;
filename tmpfile temp;
proc printto new print=tmpfile;
run;
proc report data=final nowd headline headskip split='^' missing wrap spacing=1;
column (treatment patient_id visit dose rsdtc rsdy assessor1-assessor5 adjudicator best_overall);
define treatment /"Treatment" order group width=10 left flow spacing=1;
define patient_id /"Patient^Number" order group width=8 center spacing=1;
define visit /"Visit" group order=data width=7 left spacing=1 ;
define dose /"Assigned^Dose" group width=8 spacing=1;
define rsdtc /"Assessment^Date" order group width=10 left spacing=1;
define rsdy /"Relative^Study^Day*" order group width=8 left spacing=1 ;
define assessor1 /"Assessor1" width=9 center spacing=1;
define assessor2 /"Assessor2" width=9 center spacing=1;
define assessor3 /"Assessor3" width=9 center spacing=1 ;
define assessor4 /"Assessor4" width=9 center spacing=1;
define assessor5 /"Assessor5" width=9 center spacing=1;
define Adjudicator /"Adjudicator**" width=13 center spacing=1 ;
define best_overall /"Best^Overall^Response" width=8 center ;
compute before _page_;
line @1 "14.6-28.1";
line @1 'Listing of xxxx';
line @1 ' ';
line @1 134*'--';
endcomp;
compute after _page_;
line @1 134*'-';
line @1 " ";
line @1 "Program Location: &curpathname./programs/stat/tfl/&pgmname..sas";
line @1 "Data location: &sdtm_def";
line @1 "Date/Time Report Produced: &sysdate. / &systime.";
endcomp;
run;
proc printto print=print;
run;
Hi, PROC PRINTTO is NOT making an RTF file. You are making an ASCII text file that you are opening with Microsoft Word.
A true RTF file is created with ODS RTF. You do not have ODS RTF statements in the code you show here. If you open a true ODS RTF file with Notepad, you see RTF control strings at the top of the file, as shown if I run this code and then open the resulting RTF file with Notepad:
ods rtf file='c:\temp\class.rtf';
proc print data=sashelp.class;
run;
ods rtf close;
as opposed to using PROC PRINTTO like this:
proc printto print='c:\temp\classreport.txt'; run;
proc print data=sashelp.class;
run;
proc printto; run;
You can compare the 2 outputs by opening each file with Notepad.
ODS RTF file opened with Notepad:
PROC PRINTTO file opened with Notepad:
If you actually used ODS RTF, then the file would be rendered correctly whether you were using Word 97, Word 2000 or Word 2013. ODS RTF has been using RTF control syntax ever since Word 97. When you make an ASCII text file with PROC PRINTTO and then open the text file with Word, you generally have to adjust the orientation and the font for the entire document to have the output look as it does in the LISTING window.
cynthia
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.