BookmarkSubscribeRSS Feed
Anthony_eng
Obsidian | Level 7

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.
3 REPLIES 3
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
ballardw
Super User

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?

Anthony_eng
Obsidian | Level 7

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.

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
  • 3 replies
  • 442 views
  • 1 like
  • 3 in conversation