BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KC_16
Fluorite | Level 6

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

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

5 REPLIES 5
Reeza
Super User

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.

 

 

KC_16
Fluorite | Level 6
That doesn't seem to work as the variables IN, TONS, TERS just append at the bottom of the table summing up the values.
Reeza
Super User

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.

Reeza
Super User

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;
KC_16
Fluorite | Level 6
Perfect! Thank you for your help!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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