Help using Base SAS procedures

Proc Tabulate, format comma ?

Reply
N/A
Posts: 0

Proc Tabulate, format comma ?

Having searched the web, form and documentation I am stil stumped on something that must be really simple...how to format the values in a tabulate report. The default gives nnnnnnnnnn.nn , but I need comma format to make the report more readable.

This is the simplest of cross-tab reports.
__________________________________________________________
Code:

PROC TABULATE
DATA=ECLIB000.ALL_EVENTS

OUT=SASUSER.STABSummaryTablesALL_EVENTS(LABEL="Summary Tables for ECLIB000.ALL_EVENTS")

;
VAR amount;
CLASS TO_Product / ORDER=UNFORMATTED MISSING;
CLASS FROM_Product / ORDER=UNFORMATTED MISSING;
TABLE
/* ROW Statement */
FROM_Product
all = 'Total' ,
/* COLUMN Statement */
TO_Product *(amount=' ' * Sum=' ' )
all = 'Total' *(amount=' ' * Sum=' ' ) ;
;

RUN;
____________________________________________________________________

It would be most helpful if someone would show me where the formatting instructions need to go in order to produce COMMA16. "amount" output.

Thanks in advance !
DBM
SAS Super FREQ
Posts: 8,743

Re: Proc Tabulate, format comma ?

Hi:
If statistics based on AMOUNT are all you have in your table, then a very simple way to achieve the formatting you want is to do this:
[pre]
proc tabulate data=xxxx.data f=comma16.
out=yyyyyy.data(label="Something");
[/pre]

add the f= or format= option to the PROC TABULATE statement. It can go anywhere, but must be placed before the semi-colon that ends the statement.

In more complicated situations, such as where you want some statistics to have a comma16. format, but other statistics to have the comma16.2 format (for example), you would then need to request the format in the TABLE statement. Like this:
[pre]
table Product all,
othervar*(amount=' '*Sum=' '*f=comma16.2)
all*(amount=' '*Sum=' '*f=comma16.0);
[/pre]

cynthia
N/A
Posts: 0

Re: Proc Tabulate, format comma ?

Excellent, and thank you. This works nicely.

Related question: is there any way to do this within the EG wizard ? It would seem to be an obvious requirement to format output, yet I cannot see where one has the opportunity to do so.

Thanks again for your attention and especially promptness.
SAS Super FREQ
Posts: 8,743

Re: Proc Tabulate, format comma ?

Hi:
Sadly, I do not have EG on this machine to double check, but I have some memory of right-clicking on the variable name or the statistic name and choosing Properties in order to assign a format.

cynthia
N/A
Posts: 0

Re: Proc Tabulate, format comma ?

Again thanks for your attention, Cynthia.

In EG tabulate is accessed through a wizard. When one selects the variable(s) to place in the tab construct there is no way to specify format. That is where it belongs (second screen in the EG wizard) - a useful addition - perhaps could be added to the development queue foir the benefit of the Base SAS challenged. ;-)
SAS Super FREQ
Posts: 8,743

Re: Proc Tabulate, format comma ?

HI...my memory is that when you drag and drop the variables into the table designer in the Summary Tables Task, that there is a way to Right-click on the variable name and set the format. I think it's Properties off the Right-click menu that comes up.

cynthia
Ask a Question
Discussion stats
  • 5 replies
  • 1942 views
  • 1 like
  • 2 in conversation