DATA Step, Macro, Functions and more

proc report : mislaignment issue in column labels and column data

Accepted Solution Solved
Reply
Super Contributor
Posts: 312
Accepted Solution

proc report : mislaignment issue in column labels and column data

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

original.png


Accepted Solutions
Solution
‎02-05-2017 11:50 PM
SAS Super FREQ
Posts: 8,743

Re: proc report : mislaignment issue in column labels and column data

[ Edited ]

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:

use_ODS_rtf.png

 

PROC PRINTTO file opened with Notepad:

use_PRINTTO_for_report.png

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

View solution in original post


All Replies
SAS Super FREQ
Posts: 8,743

Re: proc report : mislaignment issue in column labels and column data

Hi:
You did not show all your code. Are you using the ODS LISTING destination? Or, are you making a .LST file or a .TXT file and then opening the file in another software application?

It does not look like a complete PROC REPORT and your use of HEADLINE, HEADSKIP, SPACING and WIDTH seem to indicate that you are using LISTING output.

cynthia
Super Contributor
Posts: 312

Re: proc report : mislaignment issue in column labels and column data

[ Edited ]

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;

 

 

Solution
‎02-05-2017 11:50 PM
SAS Super FREQ
Posts: 8,743

Re: proc report : mislaignment issue in column labels and column data

[ Edited ]

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:

use_ODS_rtf.png

 

PROC PRINTTO file opened with Notepad:

use_PRINTTO_for_report.png

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

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 151 views
  • 0 likes
  • 2 in conversation