LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 17 Jul 2006 15:13:41 -0400
Reply-To:     "Gerstle, John (CDC/NCHSTP/DHAP) (CTR)" <yzg9@CDC.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Gerstle, John (CDC/NCHSTP/DHAP) (CTR)" <yzg9@CDC.GOV>
Subject:      Re: Making really nice just about ready to go tables
Comments: To: Jennifer Sabatier <plessthanpointohfive@GMAIL.COM>
Content-Type: text/plain; charset="US-ASCII"

Jennifer, This is a quick answer to your question. It can be done easily, with some work on the frontend. Once you have a template, you can re-use it with minimal modifications (using macro code as needed, especially with titles).

I'm going to skip the data step code and show some ODS and PROC REPORT...

First, I'd run a handful of PROC FREQS, output the resulting tables using ODS OUTPUT, then piece this dataset together.

i.e.: ods output onewayfreq=demog; proc freq data=foo; table (gender age education)*group / missing; run; ods output close;

...if group is your Control and Experimental groups. (You'll need to transpose the frequency or percents values by group to get the dataset below.)

Next, build the dataset you want to report out - something like so (suggested variable names in the first row - look at the ODS dataset via PROC PRINT to fix this the way you want it...):

Varname Varvalue control_pct control_num_denom exp_pct exp_num_denom Gender Male 52.6 (312/593) 54.4 (331/608) Gender Female 47.4 (281/593) 45.6 (277/608) Age < 15 years 8.2 (48/588) 7.5 (45/600) Age 15 - 45 years 79.3 (466/588) 76.7 (460/600) Age > 45 years 12.6 (74/588) 15.8 (95/600) Etc...

Assign the formatted value to Varvalue, or define a rather complicated format to cover all your demographic values. I'd create a character variable, control_num_denom, that concatenates the parentheses, numerator and denominator values for each demographic variable value.

Then the untested, simple (skips a lot of the bells and whistles) PROC REPORT code, with ODS...

Ods html file="<path>\Table 1.xls" stle=journal; Title "Table 1. Demographic characteristics (n = 1205)."; Proc report data=builtabove nowdw ; Columns (" " Varname Varvalue) ("Control/(n = 594)" control_pct control_num_denom) ("Experimental Group/(n = 611)" exp_pct exp_num_denom); Define varname / " " group ; Define varvalue / " " ; Define control_pct / "%" format=8.1; Define control_num_denom / "(frequency/total)"; Define exp_pct / "%" format=8.1; Define exp_num_denom / "(frequency/total)"; Break after varname / skip; Run; Ods html close;

Look up the vast plethora of PROC REPORT, TABULATE, with ODS papers at www.lexjansen.com

John Gerstle, MS Biostatistician Northrop Grumman CDC Information Technological Support Contract (CITS) NCHSTP \DHAP \HICSB \Research, Analysis, and Evaluation Section Centers for Disease Control and Prevention

"As far as the laws of mathematics refer to reality, they are not certain; and as far as they are certain, they do not refer to reality."

Albert Einstein, addressing the Prussian Acadamy of Science, Berlin , Jan 27, 1921

"Boss. We've got cats." "Meow" -----Original Message----- From: owner-sas-l@listserv.uga.edu [mailto:owner-sas-l@listserv.uga.edu] On Behalf Of Jennifer Sabatier Sent: Monday, July 17, 2006 2:36 PM To: SAS-L@LISTSERV.UGA.EDU Cc: Jennifer Sabatier Subject: Making really nice just about ready to go tables

I know that this is just about impossible, getting tables out of SAS that look just about ready for submission to a journal. But, perhaps I can get close.

I'm familiar, though not expert with using PROC REPORT and PROC TABULATE. I know some of this can be done using a data step and put statements and that's where I am really inexperienced.

Here's what I want my table to look like (a sample from a table I made after doing a lot of goofing around in EXCEL and WORD, taking 4 times the amount of time I'm sure it should). I hope it posts right!

Table 1. Demographic characteristics (n = 1205). Control Experimental Group (n = 594) (n = 611) Gender % (frequency/total) % (frequency/total) Male 52.6% (312/593) 54.4% (331/608) Female 47.4% (281/593) 45.6% (277/608) Age < 15 years 8.2% (48/588) 7.5% (45/600) 15 - 45 years 79.3% (466/588) 76.7% (460/600) > 45 years 12.6% (74/588) 15.8% (95/600) Education None 57.1% (335/587) 53.4% (316/592) Grades 1 - 3 4.6% (27/587) 7.9% (47/592) Grades 4 and 5 4.3% (25/587) 4.7% (28/592) Grade 6 34.1% (200/587) 34.0% (201/592)

The variables are coded, ie, Gender = 1 or 2, Age = 1, 2, or 3, etc. Missing variables are coded as . and are excluded from the calculation of percent (as you can see, the percentages come from the denominator of what data was available). I specifically want to include the correct denominator, because that's how I am representing the missingness. The total n for each group is listed in the column label.

What can I use, data stepping, any proc, whatever, to get a table in this format, with percentage signs, the parentheticals, then slash for the fraction?

If anyone has any code that comes close and I can modify it would save me HOURS of time that I could spend on actual analysis of other projects, instead of goofing around with tables.

And if you think I'm just a whiner who needs to realize that spending HOURS making tables for publication is just how it has to be, feel free to tell me that to. At least then I can move on to the next shortcut hunt...

Thanks,

Jen


Back to: Top of message | Previous page | Main SAS-L page