Date: Wed, 20 Feb 2008 21:09:59 -0500
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: count across all rows and colums
In-Reply-To: <624023F21le59U1@mid.individual.net>
Content-Type: text/plain; charset=ISO-8859-1
Here is an array approach which can be adapted to handle 16 columns to deal
with 1 million rows as desired.
The input variables can take values from 'A' to 'Z' or 'a' to 'z' keeping
them as distinct. ASCII Characters between 91 to 96 are included for
counting, if they occur.
data given;
input a $1. b $1. c $1.;
cards;
hjm
hjm
hhh
abz
;
run;
data wanted(keep=var count);
array k[65:122] _temporary_;
do until(eof);
set given end = eof;
array v[*] _character_;
do i = 1 to 3;
m = rank(v[i]);
if m < 65 or m > 122 then continue;
k[m] ++ 1;
end;
end;
do i = 65 to 122;
if k[i] then do;
var = byte(i);
count = k[i];
output;
end;
end;
run;
proc print;run;
Muthia Kachirayan
On Wed, Feb 20, 2008 at 7:48 PM, Hilly <hilly.ji@uk.co.ca> wrote:
> what would be the simplest way to summarize this across all rows and
> columns ?
>
> data a;input a $1. b $1. c $1.;
> cards;
> hjm
> jm
> hhh
> ;
> run;
>
> data _null_;set ;put(_all_)(=);run;
>
> in reality, I have 16 columns and about 1m rows of data
>
> desired totals
> h = 5
> j = 2
> m = 2
>