BookmarkSubscribeRSS Feed
Calcite | Level 5

Hi there!

I am using a format in a label in both proc freq and proc tabular for a variable of the same length (8.).

However, in proc tabular, in line breaks, a hyphen is added while in proc freq not.

The format is defined in the format statement as follows:


6=   'inter-  ven-    tionell:andere  lokale'

Here is the output of proc freq (which is what I want):


Inter-  |

ven-    |


andere  |

lokale  |


and here of proc tabulate:

Inter-  |

ven-    |


:andere |

 lokale |


You can see that in proc tabulate, an extra hypen is inserted when splitting the text.

I am using SAS9.2 under linux. Output is plain listing.


How can I control this?

Thank's for your help!

Jade | Level 19

Hi @Dondondon,


If you insert a blank after the colon in the format label, you will improve the chances that PROC TABULATE will break the line at the blank:

6=   'inter-  ven-    tionell: andere  lokale'


Calcite | Level 5
Yes, this removes the hyphen, but the word in the next line is no longer left justified.
Jade | Level 19

Strange. In my PROC TABULATE output it is left justified:



Edit: (using SAS 9.4 under Windows)


[Edit 2019-04-30: Reattached screenshot, which had been deleted by mistake.]

Super User

Post your entire proc tabulate code as options may affect behavior. Also the ods destination as the different destinations can and will have different behavior as well as the ODS style in effect.

Calcite | Level 5
proc tabulate data=c61adn_asww Format=8. ;
  class name Behandlungsart;
  table name=' ', (behandlungsart=' ' ALL='Total')*N=' '/Box='n Gesamt';

Thank's for your reply!

This is my code, "Behandlungsart" is the variable in question.

I didn't use ODS at all. All output is generated with proc printto print=output.lst in batch mode, or the Display manager in interactive mode. There is no difference whether the batch or interactive mode is used.

Calcite | Level 5

Here is a minimal working example and output:

proc format;
  value behand_az16_l8z
    5=   'inter-  ven-    tionell:andere'
    6=   'inter-  ven-    tionell:andere  lokale'
    7=   'inter-  ven-    tionell:ausschl.system.'
data bla;

  format behandlungsart behand_az16_l8z.;
  do i=5 to 7;
  drop i;

proc tabulate data=bla Format=8.;
  class behandlungsart;
  table behandlungsart=' '*N=' ';

proc freq data = bla order = internal;
    name * Behandlungsart / nopercent nocol norow    ;

Here the output:

                                                           The SAS System                           15:06 Monday, March 21, 2016   1

                                                    |        |        |inter-  |
                                                    |        |inter-  |ven-    |
                                                    |inter-  |ven-    |tionell-|
                                                    |ven-    |tionell-|:aussch-|
                                                    |tionell-|:andere |l.syste-|
                                                    |:andere | lokale |   m.   |
                                                    |       1|       1|       1|
                                                           The SAS System                           15:06 Monday, March 21, 2016   2

                                                         The FREQ Procedure

                                                  Table of name by behandlungsart

                                            name      behandlungsart

                                            Frequency|inter-  |inter-  |inter-  |  Total
                                                     |ven-    |ven-    |ven-    |
                                                     |andere  |andere  |ausschl.|
                                                     |        |lokale  |system. |
                                                   1 |      1 |      1 |      1 |      3
                                            Total           1        1        1        3

Super User

Technically you are using an ODS destination, called ODS LISTING, it just looks like text 🙂

Tabulate for listing never had much in the control over the text in the headers and what little is there is aimed at ROW headers. There doesn't appear to be any option to not print the - when tabulate is splitting text. If I had to output this to text as you are and not happy with the appearance from tabulate I would summarize the data (possibly using tabulate with OUT=) and see if I could use Proc Print as there is an explict split= option and you could add an * or other chacter to the  Label text (since formats in Print are for values).


Or move over to Proc Report.


In a last resort I go back to ancient data_null and put statements to explicitly place everything on a page, but again using summarized data.

Jade | Level 19

Thanks for providing the sample code.


It seems to me that the issue with left-alignment is restricted to column labels. But it can be solved by putting two (col. 1) or one (cols. 2 and 3) protected blanks to the end of the format labels. So, with this modification my first suggestion, to insert a blank after the colon, should work. At least it works with my SAS 9.4:



proc format;
  value behand_az16_l8z
    5=   'inter-   ven-     tionell: andere  '
    6=   'inter-   ven-     tionell: andere   lokale '
    7=   'inter-   ven-     tionell: ausschl. system. '

Again, the blanks at the end of the labels are protected blanks, 'A0'x (typed as Alt+0160).



|        |inter-  |inter-  |
|inter-  |ven-    |ven-    |
|ven-    |tionell:|tionell:|
|tionell:|andere  |ausschl.|
|andere  |lokale  |system. |
|       1|       1|       1|





Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Get the $99 certification deal.jpg



Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 8 replies
  • 3 in conversation