Help using Base SAS procedures

Creating a Column with No Statistics with Proc Tabulate

Reply
Learner
Posts: 1

Creating a Column with No Statistics with Proc Tabulate

[ Edited ]

How do I include a variable in the proc tabulate table statment and have the output simply print the values of the variable instead of computing a statistic on version 9.4?  Right now, I am getting a sum of the diff variable for each month since it's the default.

 

 

proc tabulate data=weather;

class precip month;

var temp diff;

table month*precip,temp*(max) diff;

run;

Super User
Posts: 19,815

Re: Creating a Column with No Statistics with Proc Tabulate

Please show some more details of what you may be looking for, it may be better to use PROC REPORT in this case, if no statistics are to be calculated.

Super User
Posts: 5,509

Re: Creating a Column with No Statistics with Proc Tabulate

It's very difficult to picture how your report would make any sense.  Is DIFF constant for an entire month?  If that's the case, here are some ideas you can play with to see if they come closer to what you are looking for:

 

tables month*precip, temp*max diff*mean;

 

or

 

tables month, precip*temp*max diff*mean;

Super User
Posts: 11,343

Re: Creating a Column with No Statistics with Proc Tabulate

Do you have the same value of DIFF for all records within a month*precip combination (and I won't really mention how odd it looks to see Precip which I would almost always see as a var variable in any of my data used as a class variable). If so perhaps DIFF should be a class variable on the row dimension.

 

A very good idea when dealing with data dependent questions is to post an example input data set to show us what you have and then show what the desired result for that example data should be. Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

In some very specific cases I have gotten an appearance similar to what you are requesting by using a statististic with variables in the role of your Diff but that was because I knew I was going to use tabulate to display the values and the data was structured to work with Proc Tabulate rules [In my case only one record per combination of the row class values had non-missing value for the variable in question]. Max or Min would be likely candidate statistics.

Ask a Question
Discussion stats
  • 3 replies
  • 133 views
  • 1 like
  • 4 in conversation