Hello—
I’m very new to SAS and to SAS reporting. I am trying to figure out how to produce Formatted Frequency Tables using proc report or something else. I’m having some trouble. Below are some examples of what I’m trying to produce.
Dataset for Survey 1
Office | Var1 |
Eastside | YES |
Eastside | NO |
Eastside | NO |
Eastside | YES |
Eastside | NO |
Eastside | NO |
Eastside | N/A |
Eastside | NO |
Eastside | YES |
Eastside | N/A |
Eastside | SOMETIMES |
Eastside | YES |
Eastside | N/A |
Eastside | SOMETIMES |
Westside | N/A |
Westside | YES |
Westside | YES |
Westside | YES |
Westside | YES |
Westside | SOMETIMES |
Westside | N/A |
Westside | NO |
Westside | NO |
Westside | NO |
Westside | N/A |
Westside | SOMETIMES |
Westside | SOMETIMES |
Westside | YES |
Dataset for Survey 2
Office | Var1 |
Eastside | ALWAYS |
Eastside | SOMETIMES |
Eastside | SOMETIMES |
Eastside | NEVER |
Eastside | ALWAYS |
Eastside | SOMETIMES |
Eastside | SOMETIMES |
Eastside | SOMETIMES |
Eastside | ALWAYS |
Southside | ALWAYS |
Southside | SOMETIMES |
Southside | NEVER |
Southside | NEVER |
Southside | SOMETIMES |
Southside | NEVER |
Southside | ALWAYS |
Southside | ALWAYS |
Westside | ALWAYS |
Westside | ALWAYS |
Westside | SOMETIMES |
Westside | ALWAYS |
Westside | ALWAYS |
Westside | ALWAYS |
Westside | ALWAYS |
Westside | ALWAYS |
Westside | SOMETIMES |
Westside | SOMETIMES |
Westside | ALWAYS |
Example Questions:
Var1) Do you use spreadsheets on the job?
(Var5) Do you use SAS often?
Something like this:
Survey 1 | ||||||||||
(Var1) Do you use spreadsheets on the job? | ||||||||||
YES | NO | SOMETIMES | N/A | TOTAL COUNT | ||||||
Count | Percent | Count | Percent | Count | Percent | Count | Percent | |||
Office | Eastside | 4 | 44% | 5 | 63% | 2 | 40% | 3 | 50% | 14 |
Westside | 5 | 56% | 3 | 38% | 3 | 60% | 3 | 50% | 14 | |
TOTAL | 9 | 8 | 5 | 6 | 28 |
Or, somthing like this:
Survey 2 | |||||||||
(Var5) Do you use SAS often? | |||||||||
Office | ALWAYS | SOMETIMES | NEVER | TOTAL COUNT | |||||
Count | Percent | Count | Percent | Count | Percent | ||||
Eastside | 3 | 21% | 5 | 50% | 1 | 25% | 9 | ||
Westside | 8 | 57% | 3 | 30% | 0 | 0% | 11 | ||
Southside | 3 | 21% | 2 | 20% | 3 | 75% | 8 | ||
TOTAL | 14 | 10 | 4 | 28 |
The number of Offices will vary from dataset to dataset. I would like to have the tables formatted for presentation purposes.
I thank you in advance for any assistance.
Robert,
Take a look at the various proc tabulate examples at http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000620143.htm
You can move between the examples by clicking on them in the menu at the left side of the above page.
To achieve customized html frequency distributions, using proc tabulate with ods is probably your best way to go.
In fact, the following paper provides some examples that are extremely close to your desired output: http://pharmasug.org/proceedings/2011/PO/PharmaSUG-2011-PO16.pdf
To get the HTML output, you need to use ODS.
Read the
Basically,
ODS chtml ... ;
more ODS statements ;
proc report .... ;
column ... ;
define ... ;
run;
ODS chtml close;
Or something like that.
If you have SAS/EG, I would recommend building the basic report in EG without the ODS HTML stuff first.
That will simplify getting your columns, groupings, calculations, etc.
Then once you have the framework working properly, then add the ODS elements to control the formatting of the output to give it the look and feel you want.
This whole process will take many days of trial and error learning.
I spent almost a whole week getting a set of proc reports to format into .PDF format the way I wanted.
I've spent two weeks and more when first using ODS to create some customized HTML for the first time.
If you are already competent at HTML, then it will be simpler for you.
Also, SAS has many flavors for ODS HTML output, with differing applications/use of styles and style sheets.
You have to be careful with that stuff, because one flavor embedds the style info into your base HTML file, another creates a separate style sheet that overwrites whatever is there everytime the code is ran.
All the little gotcha's will cost you days in getting a handle on what happened and why.
!! Adventures in computing !!
Thanks so much.
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 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.
Ready to level-up your skills? Choose your own adventure.