Help using Base SAS procedures

How to apply a format in Proc Tabulate, like in Proc freq?

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 13
Accepted Solution

How to apply a format in Proc Tabulate, like in Proc freq?

For example:

if we create a format:

proc format;

value quantityf

low - <0 = "Negative"

0 - 0 = "Zero"

1 - high = "Positive"

. = "Missing";

run;

we can easily apply it to proc freq procedure:

proc freq;

table quantity*group;

format quantity quantityf.;

run;

how to do the same with proc tabulate?

proc tabulate;

class quantity group;

tables quantity, group;

run;


Accepted Solutions
Solution
‎01-24-2013 02:48 AM
Trusted Advisor
Posts: 1,128

Re: How to apply a format in Proc Tabulate, like in Proc freq?

Hi,

You need to use the format option in proc tabulate on then you will be able to apply the formats,

you can write

proc tabulate data=datasetname format=formatname;

class quantity group;

tables quantity, group;

format variablename format.;

run;

Thanks,

Jagadish

Thanks,
Jag

View solution in original post


All Replies
Solution
‎01-24-2013 02:48 AM
Trusted Advisor
Posts: 1,128

Re: How to apply a format in Proc Tabulate, like in Proc freq?

Hi,

You need to use the format option in proc tabulate on then you will be able to apply the formats,

you can write

proc tabulate data=datasetname format=formatname;

class quantity group;

tables quantity, group;

format variablename format.;

run;

Thanks,

Jagadish

Thanks,
Jag
Super User
Posts: 10,460

Re: How to apply a format in Proc Tabulate, like in Proc freq?

For your classification variables you do it exactly the same as in your proc freq example.

Jagadish's example is an easy way to control a lot of summary statistics at once.

You can also override or provide specific formats for the summary statistics in a table statement:

Table classvariable,

         variable * (n*f=comma6.   mean*f=f6.2 stddev*f=3.1);

for example to provide counts in comma format, mean with 2 decimals and standard deviation with one decimal.

Occasional Contributor
Posts: 13

Re: How to apply a format in Proc Tabulate, like in Proc freq?

Thanks Jagadish and Ballardw! Exactly what I was looking for.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 210 views
  • 5 likes
  • 3 in conversation