BookmarkSubscribeRSS Feed
NewUsrStat
Lapis Lazuli | Level 10

Hi guys, 

 

I'm running the following code: 

 

title12justify=left bold height=2 color=blue "Table 2. Patients";
proc report data=tab2 nowindows spacing=1 headline headskip split= "|"  style(report)={outputwidth=100% cellspacing=0 borderwidth=1} style(header) = {font_weight = bold};

    columns group variable count percentage;
	define group/group noprint;
	define variable/display left width=10 " ";
	define count/ display center width= 10 "N";
	define percentage/ display center width= 10 "%";
	compute before group/style(lines)={just=left fontweight=bold width=50}; 
    line @1 "Group: " group  $char100.; 
endcomp;
run;

footnote1;
title1;

The Group variable contains  long sentences.

Is there a way to go "next row"? 

 

I tried:

line @1 Group $varying40.;
line @1 "" +12;

but without success.

 

Can anyone help me please?

3 REPLIES 3
Kathryn_SAS
SAS Employee

Which destination are you routing the output to? Can you send your complete code and a sample of the output? I would suggest the CELLWIDTH style attribute. Also note that I changed Group to Order on the DEFINE statement, since you cannot have Group and Display in the same report definition.

proc report data=tab2 nowindows spacing=1 headline headskip split= "|"  
 style(report)={outputwidth=100% cellspacing=0 borderwidth=1} 
 style(header) = {font_weight = bold};

columns group variable count percentage;
define group/order noprint;
define variable/display left width=10 " ";
define count/ display center width= 10 "N";
define percentage/ display center width= 10 "%";

compute before group/style(lines)={just=left fontweight=bold cellwidth=3in}; 
    line @1 "Group: " group  $char100.; 
endcomp;
run;
sbxkoenk
SAS Super FREQ

Maybe something like this ...

Note: below code was not tested.

 

I used this blog to insert a split character (~) after 50 positions.

Inserting a substring into a SAS string - SAS Users

 

data tab2;
 set tab2;
 insertposition=50;
 splitchar='~';
 length PHRASE $105;
 PHRASE = catx(' ',substr(group,1,insertposition-1),splitchar,substr(group,insertposition));
run;

proc report data=tab2 nowindows spacing=1 headline headskip split= "|"  
            style(report)={outputwidth=100% cellspacing=0 borderwidth=1} style(header)={font_weight = bold};
    column group variable count percentage;
	define group      / order   noprint;
	define variable   / display left   width=10 " ";
	define count      / display center width=10 "N";
	define percentage / display center width=10 "%";
compute before group / style(lines)={just=left fontweight=bold width=50}; 
   length part1 part2 $50;
   part1 = scan(PHRASE,1,'~');
   part2 = scan(PHRASE,2,'~');
   line part1 $50.;
   line part2 $50.;
endcomp;
run;
QUIT;

title; footnote;
/* end of program */

BR, Koen

Ksharp
Super User
data tab2;
input group :$40. variable;
length _group $ 80;
_group=cat(substr(group,1,8),'(*ESC*)n             ',substr(group,9));
cards;
aaaaaaaaaaaa 10
aaaaaaaaaaaa 20
bbbbbbbbbbbb 30
bbbbbbbbbbbb 40
;


ods rtf file='c:\temp\temp.rtf' style=journal bodytitle;
title1 justify=left bold height=2 color=blue "Table 2. Patients";
proc report data=tab2 nowindows spacing=1 headline headskip split= "|"  style(report)={outputwidth=100% cellspacing=0 borderwidth=1} style(header) = {font_weight = bold};

    columns _group variable ;
	define _group/group noprint;
	define variable/display left width=10 " ";
	compute before _group/style(lines)={just=left fontweight=bold width=50 asis=on}; 
    line @1 "Group: " _group  $100.; 
endcomp;
run;

footnote1;
title1;
ods rtf close;

屏幕截图 2026-03-07 155239.png

Catch up on SAS Innovate 2026

Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.

Explore Now →
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 450 views
  • 0 likes
  • 4 in conversation