DATA Step, Macro, Functions and more

Proc Tabulate Error

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 19
Accepted Solution

Proc Tabulate Error

I am trying to create a Proc Tabulate (Below) but get the following error message:

 

ERROR: There are multiple analysis variables associated with a single table cell in the following 

 

proc tabulate data=work.all;
class Pmt Date_new;
var In tons ters;
table (Pmt * in * tons * ters) ,
(Date_new="Month");
run;

 

I need the table to output like this if possible 

 

PMTVAROct-17Nov-17
MonthlyIn £                12 £              745,754
MonthlyTons £              510 £                      778
Monthlyters £                51 £        57,857,585
QuarterlyIn £                  1 £                         87
QuarterlyTons £        14,514 £                         78
Quarterlyters £                  1 £                           8
AnnuallyIn £                15 £                           8
AnnuallyTons £                  1 £                      785
Annuallyters £              255 £                88,878

 

i hope this makes sense, please let me know if there is anything in addition I need to support. 


Accepted Solutions
Solution
‎02-27-2018 12:52 PM
Super User
Posts: 23,987

Re: Proc Tabulate Error

I think this is close to what you want, note that I used SASHELP.STOCKS so you can run the code. 

 

You should be able to map this back to your data.

 

proc tabulate data=sashelp.stocks;
class date stock;
var open low high;
table stock*(open low high)*sum=''*f=dollar12.2, date ;
run;

View solution in original post


All Replies
Super User
Posts: 23,987

Re: Proc Tabulate Error

Try putting these as space delimited, not *

 

(Pmt * in * tons * ters)

By default though you'll get N counts. If you want the sum or mean you'll need to specify that.

 

You can find examples here: 

https://www.lexjansen.com/wuss/2016/70_Final_Paper_PDF.pdf

 

The data being used is SASHELP.CARS so you can also run and test the code in the paper.

 

 

Occasional Contributor
Posts: 19

Re: Proc Tabulate Error

That doesn't seem to work as the variables IN, TONS, TERS just append at the bottom of the table summing up the values.
Super User
Posts: 23,987

Re: Proc Tabulate Error

Given the type of summaries you're doing, you may also want to investigate the MultiLabel Format options available. 

It may help simplify some of your summaries.

Solution
‎02-27-2018 12:52 PM
Super User
Posts: 23,987

Re: Proc Tabulate Error

I think this is close to what you want, note that I used SASHELP.STOCKS so you can run the code. 

 

You should be able to map this back to your data.

 

proc tabulate data=sashelp.stocks;
class date stock;
var open low high;
table stock*(open low high)*sum=''*f=dollar12.2, date ;
run;
Occasional Contributor
Posts: 19

Re: Proc Tabulate Error

Perfect! Thank you for your help!
☑ This topic is solved.

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

Discussion stats
  • 5 replies
  • 123 views
  • 0 likes
  • 2 in conversation