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
PMT | VAR | Oct-17 | Nov-17 |
Monthly | In | £ 12 | £ 745,754 |
Monthly | Tons | £ 510 | £ 778 |
Monthly | ters | £ 51 | £ 57,857,585 |
Quarterly | In | £ 1 | £ 87 |
Quarterly | Tons | £ 14,514 | £ 78 |
Quarterly | ters | £ 1 | £ 8 |
Annually | In | £ 15 | £ 8 |
Annually | Tons | £ 1 | £ 785 |
Annually | ters | £ 255 | £ 88,878 |
i hope this makes sense, please let me know if there is anything in addition I need to support.
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;
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.
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.
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;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.