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):
and here of proc tabulate:
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!
proc tabulate data=c61adn_asww Format=8. ; class name Behandlungsart; table name=' ', (behandlungsart=' ' ALL='Total')*N=' '/Box='n Gesamt'; run;
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.
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.' ; run; data bla; format behandlungsart behand_az16_l8z.; do i=5 to 7; behandlungsart=i; name=1; output; end; drop i; run; proc tabulate data=bla Format=8.; class behandlungsart; table behandlungsart=' '*N=' '; run; proc freq data = bla order = internal; table name * Behandlungsart / nopercent nocol norow ; run;
Here the output:
The SAS System 15:06 Monday, March 21, 2016 1
| | |inter- |
| |inter- |ven- |
|inter- |ven- |tionell-|
|:andere | lokale | m. |
| 1| 1| 1|
The SAS System 15:06 Monday, March 21, 2016 2
The FREQ Procedure
Table of name by behandlungsart
Frequency|inter- |inter- |inter- | Total
|ven- |ven- |ven- |
|andere |andere |ausschl.|
| |lokale |system. |
1 | 1 | 1 | 1 | 3
Total 1 1 1 3
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.
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. ' ; run;
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.
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.