BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lillymaginta
Lapis Lazuli | Level 10
DATA HAVE;
INPUT patientid afb cvd hf db;
datalines;
1 0 1 0 1
2 1 0 0 0 
3 1 1 1 1
4 1 0 1 0 
5 1 1 1 1 

;
run; 

I have the following table, I am trying to create a summary table with sum (%) for each condition. Each patient has one row. 

afb 4 (80%) 

cvd 3 (60%)

hf 

db 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User
proc tabulate data=have;
	var  afb cvd hf db;
	table afb cvd hf db,
	      sum mean='%'*f=percent6.1
    ;
run;

Is one way for a report.

One of the many nice things about a 1/0 coded variable is the Mean is the percent of 1's.

 

View solution in original post

6 REPLIES 6
ballardw
Super User
proc tabulate data=have;
	var  afb cvd hf db;
	table afb cvd hf db,
	      sum mean='%'*f=percent6.1
    ;
run;

Is one way for a report.

One of the many nice things about a 1/0 coded variable is the Mean is the percent of 1's.

 

lillymaginta
Lapis Lazuli | Level 10

Thank you ballardw! 

novinosrin
Tourmaline | Level 20

Sir @ballardw  Nobody inspires me or makes me jealous as you do with your artistic and charm of playing with  PROC TABULATE. I seem to grip most techniques, but proc tabulate is something i'm not gripping well. Hmm I may have to dedicate a week long practice to get me up to speed. 😞

 

Nicely done!

ballardw
Super User

@novinosrin wrote:

Sir @ballardw  Nobody inspires me or makes me jealous as you do with your artistic and charm of playing with  PROC TABULATE. I seem to grip most techniques, but proc tabulate is something i'm not gripping well. Hmm I may have to dedicate a week long practice to get me up to speed. 😞

 

Nicely done!


I do thank you for the thought.

 

Once upon a time I had a client who had a tendency to keep looking at summaries and asking about "but what about grouping by   " that often involved lots of nesting in both row and columns so Proc Tabulate became a primary tool.

Sometimes  the thing is learning what the data needs to look like as well.

novinosrin
Tourmaline | Level 20

Sir @ballardw  Good afternoon,  If I may request a moment of your time. I have begun reading the documentation and a book on O'reily media on Proc report/tabulate. For some reason, I am unable to grasp quickly. Well, I am understanding the concept but seems very voluminous and hazy. I am finding it diffcult to remember options, across and display and what not. Is there a trick or a short cut method to learn it quickly or quicker than the linear approach I am taking? It's exhausting me already!

ballardw
Super User

The main thing I would suggest is keeping in mind "is the current thing I am thinking about for a page, row, or column expression".

Since Tabulate is not intended to cross statistics (you can't have a mean in a row expression that attempts to calculate an intersection with another expression in a column) that means basically placing all the statistics with either a row or column. Hence recognizing which is which is a key element with Tabulate.

The Page expression is basically only class variables and creates sub-tables for the combinations of variables that appear there.

 

The other reason to keep the row/column straight is because you have the various PCT statistics pctn, rowpctn, colpctn, pagepctn and reppctn and the respective pctsum statistics and knowing which you want is a bit easier with that.

 

After that it is basically the use of () to group like items and how to do overrides. I admit that Tabulate was a bit easier without the ODS options so adding those after knowing the basic table building syntax may have been easier. Most of what I know came from a SAS publication about Proc Report and tabulate but that is at the office and I don't remember the exact name. I think it was published for SAS 7 though. I don't remember any ODS stuff there.

 

 

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
  • 6 replies
  • 726 views
  • 4 likes
  • 3 in conversation