Help using Base SAS procedures

Formatted Frequency Tables for Reports

Reply
Frequent Contributor
Posts: 101

Formatted Frequency Tables for Reports

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

OfficeVar1
EastsideYES
EastsideNO
EastsideNO
EastsideYES
EastsideNO
EastsideNO
EastsideN/A
EastsideNO
EastsideYES
EastsideN/A
EastsideSOMETIMES
EastsideYES
EastsideN/A
EastsideSOMETIMES
WestsideN/A
WestsideYES
WestsideYES
WestsideYES
WestsideYES
WestsideSOMETIMES
WestsideN/A
WestsideNO
WestsideNO
WestsideNO
WestsideN/A
WestsideSOMETIMES
WestsideSOMETIMES
WestsideYES

Dataset for Survey 2 

OfficeVar1
EastsideALWAYS
EastsideSOMETIMES
EastsideSOMETIMES
EastsideNEVER
EastsideALWAYS
EastsideSOMETIMES
EastsideSOMETIMES
EastsideSOMETIMES
EastsideALWAYS
SouthsideALWAYS
SouthsideSOMETIMES
SouthsideNEVER
SouthsideNEVER
SouthsideSOMETIMES
SouthsideNEVER
SouthsideALWAYS
SouthsideALWAYS
WestsideALWAYS
WestsideALWAYS
WestsideSOMETIMES
WestsideALWAYS
WestsideALWAYS
WestsideALWAYS
WestsideALWAYS
WestsideALWAYS
WestsideSOMETIMES
WestsideSOMETIMES
WestsideALWAYS

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?

YESNOSOMETIMESN/ATOTAL COUNT
Count Percent Count Percent Count Percent Count Percent
Office Eastside444%563%240%350%14
Westside556%338%360%350%14

TOTAL9
8
5
6
28

Or, somthing like this:

Survey 2
(Var5) Do you  use  SAS often?
Office

ALWAYSSOMETIMESNEVERTOTAL COUNT
Count Percent Count Percent Count Percent
Eastside

321%550%125%9
Westside

857%330%00%11
Southside

321%220%375%8
TOTAL

1410428

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.

PROC Star
Posts: 7,480

Re: Formatted Frequency Tables for Reports

Posted in reply to RobertNYC

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

Occasional Contributor
Posts: 9

Formatted Frequency Tables for Reports

Posted in reply to RobertNYC

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 !!

Frequent Contributor
Posts: 101

Formatted Frequency Tables for Reports

Posted in reply to ChuckMoore

Thanks so much.

Ask a Question
Discussion stats
  • 3 replies
  • 129 views
  • 6 likes
  • 3 in conversation