DATA Step, Macro, Functions and more

Proc Print - How to get labels displayed on separate lines

Reply
Super Contributor
Posts: 272

Proc Print - How to get labels displayed on separate lines

[ Edited ]

Hi I need help in my code

 

I am running proc print with label option in it. I am using following codes.

 

 

data seven;
set six;
label  aetext='Treatment-emergent
                       Adverse Event';
run;
 
proc print data=seven label;
var aetext cnt_pct1 cnt_pct2 cnt_pct3 cnt_pct4 cnt_pct5 cnt_pct6 cnt_pct7;
run;

 

  I need output for aetext label statement 

       Treatment-emergent

        Adverse Event.

 

But my output shows like this.

 

Treatment-emergent                                                         Adverse Event

 

Thanks

Super User
Posts: 17,863

Re: Proc Print - How to get labels displayed on separate lines

[ Edited ]

Please see  Splitting Labels across Two or More Lines in the following link:

http://support.sas.com/documentation/cdl/en/basess/58133/HTML/default/viewer.htm#a001292467.htm

 

Use the SPLIT option within proc print.

 

options linesize=80 pageno=1 nodate;

proc sort data=qtr02;
   by SalesRep; 
run;

proc print data=qtr02 noobs split='/';
   var SalesRep Month Units AmountSold;
   where Month='04';
   format Units comma7. AmountSold dollar14.2;
   sum Units AmountSold;
   title 'TruBlend Coffee Maker Sales Report for April';
   label SalesRep   = 'Sales/Representative'
         Units      = 'Units/Sold'
         AmountSold = 'Amount/Sold';
   run; 
Super User
Posts: 5,085

Re: Proc Print - How to get labels displayed on separate lines

[ Edited ]

Instead of adding all those blanks in the middle of the label, add a character instead:

 

label aetext = 'Treatment-emergent*Adverse Event';

 

Then change the PROC PRINT statement to indicate that an asterisk within a label is actually an instruction to start a new line:

 

proc print data=seven split='*';

 

Using SPLIT= implies that labels are in effect, so you don't need to add the LABEL option.

 

 

Looks like Reeza is a little faster than me. Smiley Wink

 

 

Super Contributor
Posts: 272

Re: Proc Print - How to get labels displayed on separate lines

Thank you all for your support

Super User
Super User
Posts: 7,407

Re: Proc Print - How to get labels displayed on separate lines

Great advice from @Reeza@Astounding.  I would add that you may want to move to proc report.  You are generating clinical tables there, you will find that the control you have with proc report helps later on.  Another few things to remember, its likely you are going to RTF destination, you may want to put RTF tags in and control output that way also.  You can do this by using an Escape character:

ods escapechar="^";

You can do all kinds of funky things with the output then, have a look at this for example:

http://www2.sas.com/proceedings/forum2007/099-2007.pdf

 

One other thing to remember, whilst it doesn't impact on the titles, if you were to use the technique of indenting by using spaces in the data, i.e.

COL1

HEADACHE^{newline}     HEAD

This would come out without the spaces.  You need to use the option:

define COL1 / "Title" style{column}={asis=on};

Note the asis=on, this is always a headache if you don't know what to look for,

Ask a Question
Discussion stats
  • 4 replies
  • 531 views
  • 4 likes
  • 4 in conversation