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
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.
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.
Thank you ballardw!
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!
@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.
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!
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 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.