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 (June 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 28 Jun 2008 23:25:28 -0400
Reply-To:     Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Muthia Kachirayan <muthia.kachirayan@GMAIL.COM>
Subject:      Re: Table combining tables? PROC FREQ or maybe array? or checkall?
In-Reply-To:  <200806281956.m5SAlkbM007491@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

On Sat, Jun 28, 2008 at 3:56 PM, Howard Schreier <hs AT dc-sug DOT org> < schreier.junk.mail@gmail.com> wrote:

> On Sat, 28 Jun 2008 15:32:01 -0400, Peter Flom > <peterflomconsulting@MINDSPRING.COM> wrote: > > >Hi again > > > >Another weird problem, but I'm sure the wizards of SAS-L can help..... it > might be a case where Ron Fehd's checkall macro can help, but I'm not > completely sure.....Ron's macro is at > >http://www.sascommunity.org/wiki/Processing_Check-All-That-Apply > > > >Here's what I've got: > > > >1) A "check all that applies" question..... coded as a bunch of variables, > each 0, 1, or 98 (for no, yes, or missing) > >2) Another variable with three levels > > > >Here's what I want: > >A table of the second variable, for the cases where the first variables = > 1. > > > ><<< > >proc freq data = today; > > table prop_part/out = Reason1; > > where v3_1 =1; > >run; > > > >proc freq data = today; > > table prop_part/out = Reason2; > > where v3_2 =1; > >run; > >>>> > > > >etc. > > > >Which gives output that looks like: > > prop_ > >Obs part COUNT PERCENT > >1 13 . > >2 0: Non 1 0.2674 > >3 1: Som 178 47.5936 > >4 2: All 195 52.1390 > > > >for each reason. > > > >But then how do I get the results into a table that looks like this > > > > None Some All . > >Reason1 1 178 195 13 > >Reason2 > >Reason3 > > > >etc.? > > > > > > > >TIA as always > > > >Peter > > > > > > > > > > > >Peter L. Flom, PhD > >Statistical Consultant > >www DOT peterflom DOT com > > Please post data set TODAY. >

Peter:

Your sample data is missing for the prop_part taking 0 and MISSING values. I have added the first record with prop_part = 0: Som; second record with 'missing' in the sample data set used under.

A single data step solution using array and giving an output data set, NEED.

data today; input V3_1-V3_15 prop_part & $; cards; 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0: Som 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 missing 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1: Som 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 2: All 1 0 0 0 0 0 1 0 0 0 0 1 0 0 0 2: All 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 2: All 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2: All 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1: Som 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1: Som 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1: Som 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1: Som 0 1 0 0 0 0 0 0 0 0 0 1 0 0 0 2: All ; run;

data need; array count[15,0:3] _temporary_; array v v3_1-v3_15; length a $1; set today end = last; do over v; a = prop_part; * Or a = substr(prop_part,1,1); if notdigit(a) then i = 3; * Missing Value; else i = input(substr(prop_part, 1, 1), 1.); count[_i_, i] ++ (v = 1); end; if last then do reason = 1 to dim(v); none = count[reason, 0]; some = count[reason, 1]; all = count[reason, 2]; unknown = count[reason,3]; output; end; drop v: a i prop:; run;

Muthia Kachirayan


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