Your SAS programs, embedded in web apps and elsewhere

Calculate field with Tabulate

Accepted Solution Solved
Reply
Super Contributor
Posts: 497
Accepted Solution

Calculate field with Tabulate

Is there a way to use the tabulate procedure to calculate a value other than one of the default statistics? I would like to calculate the change from the base year.  Ideally I would like to calculate some values after the all line.

One way to do this is to create a second table and prefill the second table with summary data from the data layer, however the solution is not a clean as calculating inside of SAS.

I would like to create something like this.

Year123
Total434744704481
% Growth Over Prior Year2.80%0.20%
Cumulative Growth Since base year2.80%3.10%

Accepted Solutions
Solution
‎12-04-2014 05:29 PM
Super User
Posts: 11,343

Re: Calculate field with Tabulate

Posted in reply to DavidPhillips2

Not currently a feature in Proc Tabulate.

I often pre-summarize data and use tabulate to display the values but depending on what you are doing that approach might be more work than Proc Report.

View solution in original post


All Replies
Trusted Advisor
Posts: 3,214

Re: Calculate field with Tabulate

Posted in reply to DavidPhillips2

proc report?  Base SAS(R) 9.4 Procedures Guide, Third Edition is his a compute block

---->-- ja karman --<-----
Super Contributor
Posts: 497

Re: Calculate field with Tabulate

I would strongly prefer to stay with tabulate.

Solution
‎12-04-2014 05:29 PM
Super User
Posts: 11,343

Re: Calculate field with Tabulate

Posted in reply to DavidPhillips2

Not currently a feature in Proc Tabulate.

I often pre-summarize data and use tabulate to display the values but depending on what you are doing that approach might be more work than Proc Report.

SAS Super FREQ
Posts: 8,868

Re: Calculate field with Tabulate

Posted in reply to DavidPhillips2

Hi:

  TABULATE does not allow you to compute your own (extra) summary lines at the bottom of the report. ALL is what produces the summary line that you show as TOTAL and the other 2 lines would not normally be possible with TABULATE unless you faked out the data and made your own "extra" observations. PROC REPORT is more flexible and more powerful in allowing you to customize and add extra break lines to the report. As Jaap explained, it is the perfect job for a COMPUTE block.

cynthia

🔒 This topic is solved and locked.

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

Discussion stats
  • 4 replies
  • 567 views
  • 0 likes
  • 4 in conversation