Quartz | Level 8

## Line break in SAS

Hi, I have this line of code below that is spitting out a column 4 with a p-value, risk difference, and confidence interval. I want to find a way to create a line break after the p-value so that the output looks like this:

0.005 (p-value)

0.125 [0.25,1.50] (risk diff, CI)

data freq3;
length rowlabel \$100 col_1 col_2  col_3 col_4 \$32 ;
set freq1;
*rowlabel='    Risk Difference (95% CI)^{super 3}';
col_4=strip(put(p_pchi, 8.3))||strip(put(_rdif2_, 8.3))||' ['||strip(put(xl_rdif2, 8.3))||', '||strip(put(xu_rdif2, 8.3))||']';
col_1=''; col_2=''; col_3='';
roworder=2;
run;

Any help is much appreciated! Thank you!

8 REPLIES 8

## Re: Line break in SAS

@kmardinian wrote:

Hi, I have this line of code below that is spitting out a column 4 with a p-value, risk difference, and confidence interval. I want to find a way to create a line break after the p-value so that the output looks like this:

0.005 (p-value)

0.125 [0.25,1.50] (risk diff, CI)

data freq3;
length rowlabel \$100 col_1 col_2  col_3 col_4 \$32 ;
set freq1;
*rowlabel='    Risk Difference (95% CI)^{super 3}';
col_4=strip(put(p_pchi, 8.3))||strip(put(_rdif2_, 8.3))||' ['||strip(put(xl_rdif2, 8.3))||', '||strip(put(xu_rdif2, 8.3))||']';
col_1=''; col_2=''; col_3='';
roworder=2;
run;

Any help is much appreciated! Thank you!

I would make another observation for the second row.  Splitting within the cell can be done with the split character assuming something like PROC REPORT but you will need to supply more info.

SAS Super FREQ

## Re: Line break in SAS

Hi:
What is your destination of interest? RTF, PDF, HTML, Excel? Normally, you would use a ESCAPECHAR and {newline} to insert a line break. but it depends on the destination, which you don't show. You only show creating the variable, you don't show how you're displaying the variable -- ODS RTF? ODS PDF??? What procedure? PRINT, REPORT???

Cynthia
Quartz | Level 8

## Re: Line break in SAS

Hi Cynthia,

I am using Proc Report, I have pasted some of the code I've been using!

Calcite | Level 5

## Re: Line break in SAS

Hi, Cynthia:

I recalled there were some special line break commands associated with escapechar, such as ~m (to specify the break location of a string)  and ~-2n(to force a line wrapping corresponding to ~m location). Are those commands still supported by SAS 9.4?

e,g.

....

computer after;

line "abbreviation:  ~mN = Total subjects treated with the study drug ...    ~-2nM= subjects who discontinued treatment..." ;

endcomp;

SAS Super FREQ

## Re: Line break in SAS

Hi:
There were some special line breaking and line wrapping ESCAPECHAR commands in the original version of ODS ESCAPECHAR (V8.2). However, when ESCAPECHAR was revamped for SAS 9 I believe the special ones were deprecated and may not work in any destinations.
Cynthia
Calcite | Level 5

## Re: Line break in SAS

Thanks, Cynthia!

However, if I want to reserve some monocharacters, say 7 char spaces in the next row indentation, adding  ~_~_~_~_~_~_~_ of using pretext = '\pnhang\fi-222\li222 ' (hard to locate exact position) is not convenient. Is there any better way to achieve the same results?

Best Regards

Don

example: a footnote as followings in a rtf table:

Abbreviation: N = ............, n = .............., m = ...........;

R = ......;  T = .......;                  (indentation aligned up with the first-row text)

SAS Super FREQ

## Re: Line break in SAS

Hi: Most of the ODS output is proportional spaced font, so I"m not sure what you mean by "monocharacters". If you are going to change to a monospace font like Courier New, then number of spaces might work. The FLOW option is ignored for ODS destinations. What is your destination of interest. Did I miss whether you were using ODS RTF, ODS PDF, ODS HTML or ??? I see you mention RTF control strings, but I did not see ODS RTF statements in the code you posted. My tendency is to use INDENT= or LEFTMARGIN=, I think I've posted examples of both of those, but they depend on the destination.
Cynthia
Quartz | Level 8

## Re: Line break in SAS

Ok, making another option was going to be my second option. I assumed I could split in the data step. If I create a new observation where they are both in column 4 so that it was like this:

data freq2;
length col_4 \$32;
set freq1;
col_4=strip(put(p_pchi, 8.3));
roworder=2;
outcome=1;
run;

data freq3;
length rowlabel \$100 col_1 col_2  col_3 col_4 \$32 ;
set freq1;
*rowlabel='    Risk Difference (95% CI)^{super 3}';
col_4=strip(put(_rdif2_, 8.3))||' ['||strip(put(xl_rdif2, 8.3))||', '||strip(put(xu_rdif2, 8.3))||']';
col_1=''; col_2=''; col_3='';
roworder=2;
run;

But then how would I split it in the proc report statement?

proc report nowd center spanrows missing data=all split='*'   list out=test
style(report)=[width=100% frame=void rules=none cellspacing=0 padding=1pt font=('Courier New', 8pt)]
borderbottomcolor=black borderbottomwidth=1
background=white font=('Courier New', 8pt) textalign=c ]
style(column)=[font=('Courier New', 8pt)  ASIS=ON ] ;

columns  roworder rowlabel ("X*(N=&N1.)" col1) ("Y*(N=&N2)" col2) ("Total*(N=&N3)" col3) ('p-value^{super 1}*Risk Difference^{unicode delta_u}(95% CI)' col_4);
*define _PB_page/group noprint;
* define vorder/order noprint;
define roworder/order noprint;
define rowlabel/display '' style(column)=[width=1.5in] flow;

define col1/display  '' style(column)=[width=0.8in] center flow;
define col2/display ''  style(column)=[width=0.8in] center flow;
define col3/display '' style(column)=[width=0.8in] center flow;
define col_4/display ' '  style(column)=[width=1.2in] center flow;

Discussion stats
• 8 replies
• 17597 views
• 0 likes
• 4 in conversation