BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
fengyuwuzu
Pyrite | Level 9

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

1 ACCEPTED SOLUTION

Accepted Solutions
Cynthia_sas
SAS Super FREQ

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

3 REPLIES 3
Cynthia_sas
SAS Super FREQ
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
fengyuwuzu
Pyrite | Level 9

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;

 

 

Cynthia_sas
SAS Super FREQ

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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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