BookmarkSubscribeRSS Feed
kmardinian
Quartz | Level 8

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
data_null__
Jade | Level 19

@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.

Cynthia_sas
SAS Super FREQ
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
kmardinian
Quartz | Level 8

Hi Cynthia,

 

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

 

Thank you for your help!

DonZ
Calcite | Level 5

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;

Cynthia_sas
SAS Super FREQ
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
DonZ
Calcite | Level 5

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)

 

Cynthia_sas
SAS Super FREQ
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
kmardinian
Quartz | Level 8

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)]
style(header)=[bordertopcolor=balck bordertopwidth=1
               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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 8 replies
  • 16839 views
  • 0 likes
  • 4 in conversation