Date: Fri, 17 Jan 1997 13:36:00 -0500
Reply-To: Dave_Mabey_at_RDA8POSTOFFICE1%RDCCMAIL%READERSDIGEST@RMAIL.COM
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Dave_Mabey_at_RDA8POSTOFFICE1%RDCCMAIL%READERSDIGEST@RMAIL.COM
Subject: Re[2]: comm1-comm6 problem
Content-type: text/plain; charset=US-ASCII
New Text Item: Re: comm1-comm6 problem
Lisa,
I would use the following.
PROC SQL;
select case when comm1 ne . then comm1
when comm2 ne . then comm2
when comm3 ne . then comm3
when comm4 ne . then comm4
when comm5 ne . then comm5
when comm6 ne . then comm6
when comm7 ne . then comm7
else -1
end as index,
count(*)
from comfile
group by index;
** Generic Signature **
______________________________ Reply Separator ____________________________
_____
Subject: Re: comm1-comm6 problem
Author: j_weedon@ESCAPE.COM@INTERNET at RDNOTES
Date: 1/16/97 11:11 AM
(Embedded image moved to file: PIC001.PCX)
On Thu, 16 Jan 1997 08:51:23 -0500, Lisa Bastian <eagle89@EROLS.COM> wrote:
>I have a total of about 67 codes (numeric), any of which can be found
>among six consecutive fields (comm1 comm6), although for each
>observation, a code can only show up once. Is there any "easy" way to
>count the occurrence of each individual code? ie., without an array and
>a bunch of "if" statements? Thanx.
Please put a subject line in your posts.
Does this do what you want:
%macro comms;
data new (keep=comm);
set old (keep=comm1-comm6);
%do i=1 %to 6;
comm=comm&i; output;
%end;
proc freq data=new;
run;
%mend; %comms
I'm not sure what your aversion to arrays is, but a non-macro solution with
an array would be:
data new (keep=comm);
set old (keep=comm1-comm6);
array comms comm1-comm6;
do over comms;
comm=comms; output;
end;
proc freq data=new;
run;
Jay Weedon.
SMTPOriginator: owner-sas-l@VM.MARIST.EDU