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 (November 1998, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 30 Nov 1998 16:31:51 -0800
Reply-To:     "Lanning, Chris" <clanning@AMGEN.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         "Lanning, Chris" <clanning@AMGEN.COM>
Subject:      Re: Mattrix?
Comments: To: "ecolwell@WELLSFARGO.COM" <ecolwell@WELLSFARGO.COM>
Content-Type: text/plain

This should give you what you want...

dm output 'clear'; dm log 'clear';

/* Give us some data to play with */ data test; retain seed -1; array flag flag1-flag4; do i = 1 to 100; do j = 1 to 4; flag(j) = round(ranuni(seed)); end; output; end;

proc print;

/* Generate the frequencies you desire */ proc freq data=test; tables flag1*flag2*flag3*flag4 / out=test2 noprint;

proc print data=test2;

run;

Chris Lanning Trilogy Consultant clanning@amgen.com 1-805-447-0634 SAS Consulting is my life!!!

> ---------- > From: Esther Colwell[SMTP:ecolwell@WELLSFARGO.COM] > Reply To: ecolwell@WELLSFARGO.COM > Sent: Monday, November 30, 1998 3:45 PM > To: SAS-L@UGA.CC.UGA.EDU > Subject: Mattrix? > > (Please send any responses to ecolwell@wellsfargo.com > <mailto:ecolwell@wellsfargo.com> in addition to > the list as I do not receive all of the SAS-L posts). > > > I have a data set with eleven binary flags and I need to create > a summary file with the frequency of all possible combinations. > For example, assume there are four flags, flag1 flag2, flag3, and > flag4. I would like to know: > > Total number of records with: > > flag1 > flag2 > flag3 > flag4 > flag1 + flag2 > flag1 + flag3 > flag1 + flag4 > flag2 + flag3 > flag2 + flag4 > flag3 + flag4 > flag1 + flag2 + flag3 > flag1 + flag2 + flag4 > flag1 + flag3 + flag4 > > (etc....) > > > I am considering creating a matrix-like file with all of the possible > combinations and > using sql to merge this file with the main data set. I would assign a id > variable, NEWFLAG, > and use proc format to describe which flags matched for each NEWFLAG. > > e.g. > > data test; > input flag1 - flag4 newflag; > cards; > 1 0 0 0 1 > 0 1 0 0 2 > 0 0 1 0 3 > 0 0 0 1 4 > 1 1 0 0 5 > 1 0 1 0 6 > 1 0 0 1 7 > 0 1 1 0 8 > 0 1 0 1 9 > 0 0 1 1 10 > 1 1 1 0 11 > 1 1 0 1 12 > 1 0 1 1 13 > (etc...) > ; > run; > > > Before I embark on this tedious coding, is there an easier > method to complete this task? > > PLEASE NOTE: I am deeply appreciative of any suggestions, hints, or > pointers > - > a complete solution is not required. Thank you! >


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