BookmarkSubscribeRSS Feed
oussema
Obsidian | Level 7

Hello all, 

I created the table in the attached file using this program:

proc tabulate data=sashelp.cars out=want missing ;
	class DriveTrain Origin Type ;
	var Horsepower;
	table Horsepower='Horsepower'*(n='n' mean='Mean' std='Standard Deviation' min='Min' max='Max') 
      	DriveTrain='train' * (n='n' colpctn='%')
	  	Origin='origin' * (n='n' colpctn='%'),(Type=" ") (all='Overall');
run;

what I want is producing a sas table named 'want' and showing exactly what in the image in the attached file(same rows and same columns) .

PS: I can use proc freq many times by subsetting every time and then merging all output tables but I'm searching for a method which is easier and in some lines.

Any suggestion plz ?

 

2 REPLIES 2
HB
Barite | Level 11 HB
Barite | Level 11

I can't see your RTF file so I don't know exactly what you are producing, but when you say you want to produce a SAS table what exactly do you mean?  Do you mean you want to create a dataset out of the output of your proc tabulate procedure?

ballardw
Super User

As you created a data set want with that code then I have to assume that you need to modify that resulting data set to another format.

The are going to be issues that include transposing data to get variables to have names/label of the column headers that are currently in the variable named Type. You would also have to create single variable to hold the name of the statistic.

 

You might find it easer to use three proc tabulate statements and create the horsepower, train and origin summaries separately and modify each before appending. Note that if you want a line with "train" or "origin" with no actual values you would have to add them manually. Or at least different TABLE statements to select by table.

 

Some sorts of data sets aren't "easy" to make because they really don't make much sense. Have a single data set where one variable contains counts, a mean, a standard deviation, a max, a min and percentages is a problem waiting to happen when the set is used incorrectly. Errors involved with other manipulations, which would be the reason for a data set, are going to be extremely complex.

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2203 views
  • 0 likes
  • 3 in conversation