The SAS Output Delivery System and reporting techniques

proc tabulate - print reports in order

Reply
Occasional Contributor
Posts: 9

proc tabulate - print reports in order

Hi SAS experts,

 

I have a dataset that has gender groups (0, 1) nested in departments.

I'd like to use Proc Tabulate to generate some reports by department and by gender. 

 

Here is what I need to produce:

 

Table 1:

Account department, Male

N, 1 Year Retention, 2 Year Retention

20, 20%, 30%

 

Table 2:

Account department, Female

N, 1 Year Retention, 2 Year Retention

40, 22%, 30%

 

Table 3:

Payroll department, Male

N, 1 Year Retention, 2 Year Retention

40, 21%, 10%

 

etc. etc..

 

However, using proc tabulate

by department gender ;

 

Gives me tables in the following undesired order:

 

Account department, Male

Payroll department, Male

Account department, Female

Payroll department, Female

etc.

 

I really want:

Account department, Male

Account department, Female

Payroll department, Male

Payroll department, Female

 

How do I fix this?

 

Thanks so much!

 

 

 

Super Contributor
Posts: 406

Re: proc tabulate - print reports in order

From what you write your output should be as desired. Do your variables have formats perhaps? The ordering can be accordiung to unformatted values. Anyways please share your code and data. No doubt with more info the issue will be resolved quickly. 

 

Regards, Jan.

Grand Advisor
Posts: 10,194

Re: proc tabulate - print reports in order

Show the exact code you used. The order of variables in the table statement is important. And while Tabulate will supporat BY variables often it is best to use those as CLASS variables and provide them in a page dimension.

Order of appearance will depend upon Order=options and the order variables appear in parts of the proc.

 

If you provide some example data in the form of a datastep we can test and provide exact code.

Grand Advisor
Posts: 9,567

Re: proc tabulate - print reports in order

1)Use proc tabulate option :   Order=DATA 
2)Padding some white blank before the value to customize the order .

Ask a Question
Discussion stats
  • 3 replies
  • 326 views
  • 0 likes
  • 4 in conversation