Hello All,
I am using SAS EG 8.3. I have provided my code below. I want to add the MEAN and MODE for each of the columns, but I receive the error shown below when I try to include MEAN and/or MODE. The code works fine if I take out the 'MODE' shown below on the TABLE line. The total for each column generate without error when using 'ALL'. I thought maybe my data was in the wrong format, but the totals are added correctly. Thank you for your time.
PROC TABULATE DATA=WORK.DYNAMIC; CLASS YEAR MODEL EXPERIMENTID CODE; TABLE YEAR*MODEL, EXPERIMENTID ALL MODE, CODE; ODS OUTPUT Table = WORK.COUNTSTUFF; RUN;
ERROR: Statistic other than N was requested without analysis variable in the following nesting : YEAR * MODEL * Mode * CODE.
Mode is not a statistic that PROC TABULATE can compute.
Instead, compute the mode in PROC SUMMARY, store the mode in a variable in your data set and then have TABULATE include the mode variable in a table.
Any numeric variables that you want to request a statistic other than one of the n or pctn such as Mean, Max, Min etc first requires that the variable appear on a VAR statement to indicate the role of the variable.
Then you need to make sure that the variable is associated with the statistic(s) with an * between the variable and statistics.
Please look at the documentation for Proc Tabulate in the Examples to see example tables. Also you may want to check the documentation of the Table statement for the Statistic Keywords available.
Question: did you intend to make a separate table for each combination of Year and Model?
Thank you I will review that. I will review the documentation and add the VAR as required.
As for your question, yes. I wanted a separate table for each Year/Model combination.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.