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 (January 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 31 Jan 2007 12:57:44 -0500
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject:      Re: calculating percentages in proc report
Content-Type: text/plain; charset=ISO-8859-1

On Sun, 28 Jan 2007 16:42:25 -0500, Janet Carlson <janet.carlson@NDSU.EDU> wrote:

>hi proc report experts >I am new to proc report and need to put the results of a 500 variable >survey into proc report. The survey is in sections so I am approaching it >by trying to do this in sections. Example satisf1 – satisf15, var1 – >var10, x1 – x12 >The format of the report would be: >Var1 Male female total > 25 20 30 > 15 10 15 > 20 30 20 > 10 25 10 > 30 15 25 > 100 100 100 > >Same for var2 – var10 >Then x1 – x12 >Then satisf1 – satisf15 ect. > >I am able to get the total column to sum to 100 but have been unable to >get the male and female columns to sum to 100. everything I try I get the >percentages for male and female to sum to 100 for the entire section not >the individual variable. >Following is a small data set and my attempt at proc report. I am >changing the sections of variables into a univariate structure. I need >to know how to get the male and female totals to sum to 100 by each >variable. Also any suggestions are welcome. Should I approach this >differently? Like I said this is a first attempt at working with proc >report. >Thank you.

[snip]

I've made a bunch of non-critical changes to the original code to eliminate some distractions, make things less roundabout, and make the output more compact.

data yfcy06; input obs sex06a $ intact1-intact4; cards; 1 F 2 1 2 2 2 F 3 2 3 3 3 F 4 3 3 4 4 F 5 1 2 1 5 F 5 5 4 4 6 F 3 5 2 2 7 F 2 2 2 2 8 F 2 3 4 5 9 F 1 1 1 1 10 F 1 2 2 5 11 M 3 1 2 1 12 M 2 3 1 4 13 M 3 2 1 . 14 M 2 1 2 2 15 M 1 3 2 2 16 M 4 2 2 2 17 M 5 5 3 3 18 M 5 5 4 5 19 M 4 2 3 4 20 M 5 5 2 2 ;

proc transpose data=yfcy06 out=aa(rename = (_name_=qall col1=intact) ); by obs sex06a; run;

data aaa; set aa; intacta=intact; label qall = 'Who/Where'; run;

proc format; value $sex F='Male' M='Female'; value intact 1='Never' 2='1-2 / term' 3='1-2 / month' 4='1 / week' 5='2-3 / week' 6='Daily'; value $intactq 'intact1' = 'Faculty in' 'intact2' = 'Faculty out' 'intact3' = 'Advisors' 'intact4' = 'Other'; run;

proc report nowindows ;

column qall intact sex06a, (pctn) intacta n pctntot;

define qall / group order=data format= $intactq.; define intact / group order=internal format=intact.; define sex06a / across format=$sex.; define intacta / analysis n noprint; define pctntot / computed format=percent8.1; define pctn / format=percent8.1;

compute pctntot; pctntot = intacta.n / pctnn; endcomp;

compute before qall; pctnn = intacta.n; endcomp;

break after qall / skip summarize;

run;

If I understand correctly, Janet wants the denominators for the PCTN stats to be at the QALL group level. I see nothing in the code to make that happen and I'm not a REPORT export, so I have no suggestion.

Meanwhile, the output looks like this:

sex06a Who Female Male Where intact pctn pctn n pctntot Faculty in Never 2.6% 5.0% 3 15.0% 1-2 / term 5.1% 7.5% 5 25.0% 1-2 / month 5.1% 5.0% 4 20.0% 1 / week 5.1% 2.5% 3 15.0% 2-3 / week 7.7% 5.0% 5 25.0% Faculty in 25.6% 25.0% 20 100.0%

Faculty out Never 5.1% 7.5% 5 25.0% 1-2 / term 7.7% 7.5% 6 30.0% 1-2 / month 5.1% 5.0% 4 20.0% 2-3 / week 7.7% 5.0% 5 25.0% Faculty out 25.6% 25.0% 20 100.0%

Advisors Never 5.1% 2.5% 3 15.0% 1-2 / term 12.8% 12.5% 10 50.0% 1-2 / month 5.1% 5.0% 4 20.0% 1 / week 2.6% 5.0% 3 15.0% Advisors 25.6% 25.0% 20 100.0%

Other Never 2.6% 5.0% 3 15.8% 1-2 / term 10.3% 7.5% 7 36.8% 1-2 / month 2.6% 2.5% 2 10.5% 1 / week 5.1% 5.0% 4 21.1% 2-3 / week 2.6% 5.0% 3 15.8% Other 23.1% 25.0% 19 100.0%

The 7.5% in the first row should be 30%, etc.


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