BookmarkSubscribeRSS Feed
PeterMehnert
Calcite | Level 5
I use PROC REPORT to produce a simple frequency table from two character variables which are categorized. The Table is produced via ODS as PDF output with an tailored style definition.
The cells simply contain the frequency counts from all the possible combinations of the categories. Now I want to apply a different format to the cells (eg. a COMMAX format). I tried many things in the style definition and the report definition but it didn't work at all. I also checked out the Doc how to apply the format.

Any hints?
Thanks
Peter
4 REPLIES 4
David_SAS
SAS Employee
Peter,

You can use the FORMAT option on the DEFINE statement, e.g.:
[pre]
define priority/order order=internal "Priority" format=prty10.;
[/pre]

-- David Kelley, SAS
PeterMehnert
Calcite | Level 5
David,

thanks for your response.

The problem is that (in your example) priority is a character variable. Therefore a numeric format wouldn't work. The frequency values in the table are printed in best. format (eg. 23419), but the customer wants to have it in commax. format like 23.419.

Thanks
Peter
Cynthia_sas
Diamond | Level 26
Hi, Peter:
Here's a thought, are you explicitly using the N statistic in your PROC REPORT? If you are taking the default count for character variables in your table, you might be able to achieve what you want by trying something like this.
[pre]
column Product Region,N;
define Product / group;
define Region / across;
define N / format=commax6. 'CNT';
[/pre]

Proc Tabulate might also serve your needs better because with PROC TABULATE, you can apply a format to all the data cells on the TABULATE statement:
[pre]
PROC TABULATE data=something format=commax6.;
[/pre]

cynthia
PeterMehnert
Calcite | Level 5
Hi Cynthia,

thanks for your response. Your first proposal did work! I already used the N statistic for the row totals, but using an alias like

column Product Region,N=NCELL N;
define Product / group;
define Region / across;
define NCELL / format=commax6. 'CNT';
define N / format=commax6. 'TOT';

brought the desired results.

Thanks again
Peter

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1440 views
  • 0 likes
  • 3 in conversation