<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using an ARRAY to count number of records with certain conditions? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71693#M20706</link>
    <description>using ARRAY for this is difficult because the number of counters is practically unknown. Beginning in SAS9 we have dynamic(defined during runtime) storage like array, but called hash. &lt;BR /&gt;
With the 10 columns of the original data, index a hash table incrementing a (data item in the hash) counter  for each of the thousands of rows of original data. Once filled, save the hash to a data set. That provides the counters for all combinations present in your data. &lt;BR /&gt;
almost an array (at one time it was referred to as an associative array, but hash was deemed a suitable alternate name and sticks to the concept).  &lt;BR /&gt;
peterC</description>
    <pubDate>Wed, 01 Jun 2011 13:31:40 GMT</pubDate>
    <dc:creator>Peter_C</dc:creator>
    <dc:date>2011-06-01T13:31:40Z</dc:date>
    <item>
      <title>Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71689#M20702</link>
      <description>Hi all,&lt;BR /&gt;
&lt;BR /&gt;
I have ten columns and thousands of rows of data that contain a number between 1 and 71 OR a letter between A and J, each representing a different characteristic of an observation.  Each observation can have multiple characteristics, so I've already separated these out into "characteristic" columns to separate each number/letter (example: if an observation originally had characteristics 1, 4, 7, and J, it would have been shown as "N: 1; 4; 7; J" I have separated this out into four columns (CHAR_1, CHAR_2, CHAR_3, and CHAR_4) to separate each characteristic out, so now there are four columns, each of which would contain one of the four number/letter codes).&lt;BR /&gt;
&lt;BR /&gt;
My goal is to use an ARRAY (or some other function if more appropriate) to search across every single observation and column to get a count of every single observation that has each number/letter and output it into a table that lists every single number and letter with a count of each (for instance, if code "11" popped up 6 times in CHAR_1, 4 times in CHAR_2, 83 times in CHAR_3, and 0 times in CHAR_4, the table would have two columns: CHAR would be 11 and COUNT would be 93.  This would be performed for each code, 1 - 71 and A - J).&lt;BR /&gt;
&lt;BR /&gt;
Bonus points if someone has any advice on how to encorporate an INDEX or SCAN function into this to eliminate the need for separating each characteristic out into its own column before performing the array.&lt;BR /&gt;
Thanks in advance!</description>
      <pubDate>Tue, 31 May 2011 21:04:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71689#M20702</guid>
      <dc:creator>JonathanWarrick</dc:creator>
      <dc:date>2011-05-31T21:04:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71690#M20703</link>
      <description>My approach to this, assuming that the other or orignal variables aren't of much concern would be instead of parsing one column out to 4 variables as in your example but to create only one variable with the CHAR value but output it 4 times.&lt;BR /&gt;
&lt;BR /&gt;
Something like:&lt;BR /&gt;
data charset (keep=char);&lt;BR /&gt;
   set datasetname;&lt;BR /&gt;
   array vars var1-var10;/* your columns you want to scan*/&lt;BR /&gt;
   do i= 1 to dim (vars);&lt;BR /&gt;
      j=1;&lt;BR /&gt;
      Char = scan(var&lt;I&gt;,j);&lt;BR /&gt;
      do while char ne '';&lt;BR /&gt;
          output;&lt;BR /&gt;
          j=j+1;&lt;BR /&gt;
         char=scan(var&lt;I&gt;,j);&lt;BR /&gt;
      end;&lt;BR /&gt;
   end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc freq data=charset;&lt;BR /&gt;
   table char;&lt;BR /&gt;
run;&lt;/I&gt;&lt;/I&gt;</description>
      <pubDate>Tue, 31 May 2011 22:51:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71690#M20703</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-05-31T22:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71691#M20704</link>
      <description>BallardW answer is perfectly correct. &lt;BR /&gt;
&lt;BR /&gt;
Another data struture that might be useful is &lt;BR /&gt;
var1 var2 --- vara varb &lt;BR /&gt;
1 0  ---1 0  &lt;BR /&gt;
&lt;BR /&gt;
Basically a column for each possible answer and a 1 or 0 if that occurs. &lt;BR /&gt;
&lt;BR /&gt;
You can do this from ballardw dataset by adding an observation 1 and transposing the data using proc transpose.</description>
      <pubDate>Tue, 31 May 2011 23:16:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71691#M20704</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2011-05-31T23:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71692#M20705</link>
      <description>Hi Jonathan&lt;BR /&gt;
&lt;BR /&gt;
In case ballardw's proposition doesn't suit the layout of your source data I would suggest that you post a data step creating some sample data and then give us an example how the result should look like.&lt;BR /&gt;
&lt;BR /&gt;
Cheers&lt;BR /&gt;
Patrick</description>
      <pubDate>Wed, 01 Jun 2011 09:41:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71692#M20705</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2011-06-01T09:41:00Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71693#M20706</link>
      <description>using ARRAY for this is difficult because the number of counters is practically unknown. Beginning in SAS9 we have dynamic(defined during runtime) storage like array, but called hash. &lt;BR /&gt;
With the 10 columns of the original data, index a hash table incrementing a (data item in the hash) counter  for each of the thousands of rows of original data. Once filled, save the hash to a data set. That provides the counters for all combinations present in your data. &lt;BR /&gt;
almost an array (at one time it was referred to as an associative array, but hash was deemed a suitable alternate name and sticks to the concept).  &lt;BR /&gt;
peterC</description>
      <pubDate>Wed, 01 Jun 2011 13:31:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71693#M20706</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-06-01T13:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71694#M20707</link>
      <description>Thanks for the help so far.  BallardW's solution is not exactly what I'm looking for because there are situations in which I don't want the CHAR to be counted.&lt;BR /&gt;
&lt;BR /&gt;
Here is some sample, simplified code that can be used to show exactly what I'm looking to do:&lt;BR /&gt;
&lt;BR /&gt;
data test;&lt;BR /&gt;
input num CHAR_1 $2. CHAR_2 $2. CHAR_3 $2. CHAR_4 $2. CHAR_5 $2. CHAR_6 $2.;&lt;BR /&gt;
DATALINES;&lt;BR /&gt;
1 f 1 33 52 a b&lt;BR /&gt;
2 Y&lt;BR /&gt;
3 33&lt;BR /&gt;
4 1&lt;BR /&gt;
5 33 a b c&lt;BR /&gt;
6 Y&lt;BR /&gt;
7 18 19 20&lt;BR /&gt;
8 f 33&lt;BR /&gt;
9 a j&lt;BR /&gt;
10 1 44&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
The result would look like this:&lt;BR /&gt;
&lt;BR /&gt;
CHAR    COUNT&lt;BR /&gt;
1           3&lt;BR /&gt;
2           0&lt;BR /&gt;
3           0&lt;BR /&gt;
...    &lt;BR /&gt;
18         1&lt;BR /&gt;
19         1&lt;BR /&gt;
20         1&lt;BR /&gt;
...&lt;BR /&gt;
33         4&lt;BR /&gt;
...&lt;BR /&gt;
44         1&lt;BR /&gt;
...&lt;BR /&gt;
52         1&lt;BR /&gt;
...&lt;BR /&gt;
a           3&lt;BR /&gt;
b           2&lt;BR /&gt;
c           1&lt;BR /&gt;
...&lt;BR /&gt;
f            2&lt;BR /&gt;
...&lt;BR /&gt;
j            1&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
In my original post, I referred to giving bonus points to someone who could take out a few steps for me (parsing the CHAR var into separate variables).  I didn't show it in my sample data set, but the way the original, un-parsed CHAR variable looks (for row 1) is: N:f; 1; 33; 52; a; b.  If the CHAR variable does NOT pass the test, it spits out an "N:" first and then lists the corresponding codes it violated.  If it passes all tests, like in rows 2 and 6, it will simply spit out a "Y" and nothing else.  I do not care about the "Y" responses and I need to always drop the first two characters of the "N" responses (the "N:" would always be dropped).&lt;BR /&gt;
&lt;BR /&gt;
Thinking about things a little further, I'd like to do a "Y" or "N" flag approach (or 1/0) for each possible CHAR code (1 - 71, a - j) so I can merge this back into the larger dataset and do analysis on certain combinations.  &lt;BR /&gt;
&lt;BR /&gt;
Hopefully this extra information helps!  Thanks again!</description>
      <pubDate>Wed, 01 Jun 2011 14:32:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71694#M20707</guid>
      <dc:creator>JonathanWarrick</dc:creator>
      <dc:date>2011-06-01T14:32:20Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71695#M20708</link>
      <description>Peter - can you please explain a little further or provide me with a link to some documentation where I can read about this to see if it would be appropriate?</description>
      <pubDate>Wed, 01 Jun 2011 14:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71695#M20708</guid>
      <dc:creator>JonathanWarrick</dc:creator>
      <dc:date>2011-06-01T14:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71696#M20709</link>
      <description>Maybe I don’t understand your problem exactly, but it seems to me that the array/hash solution is a bit more complicated that necessary.  Will this solution work? [pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
input @1 num @4 CHAR_1 $2. @7 CHAR_2 $2. @10 CHAR_3 $2. @13 CHAR_4 $2. @16 CHAR_5 $2. @19 CHAR_6 $2.;&lt;BR /&gt;
DATALINES;&lt;BR /&gt;
1  f  1  33 52 a  b &lt;BR /&gt;
2  Y &lt;BR /&gt;
3  33&lt;BR /&gt;
4  1 &lt;BR /&gt;
5  33 a  b  c &lt;BR /&gt;
6  Y &lt;BR /&gt;
7  18 19 20&lt;BR /&gt;
8  f  33&lt;BR /&gt;
9  a  j&lt;BR /&gt;
10 1  44&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data all_chars(keep=char);&lt;BR /&gt;
	length char $ 2;&lt;BR /&gt;
	do i=1 to 71;&lt;BR /&gt;
		char=put(i,2.);&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	do j= 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j';&lt;BR /&gt;
		char=j;&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data test1(keep=val);&lt;BR /&gt;
	set test;&lt;BR /&gt;
	array char{*} char_:;&lt;BR /&gt;
	do i=1 to dim(char);&lt;BR /&gt;
		if char{i} ne '' then do;&lt;BR /&gt;
			val=char{i};&lt;BR /&gt;
			output;&lt;BR /&gt;
		end;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
	create table counts as&lt;BR /&gt;
	select char, coalesce(count, 0) as count&lt;BR /&gt;
	from all_chars left join &lt;BR /&gt;
		(select distinct val as val, count(*) as count&lt;BR /&gt;
		 from test1&lt;BR /&gt;
		 group by val) as counts&lt;BR /&gt;
	on trim(left(char))=trim(left(val))&lt;BR /&gt;
	order by char;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 01 Jun 2011 16:49:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71696#M20709</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2011-06-01T16:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71697#M20710</link>
      <description>here is a link to the doc for the statement that writes a hash table to a data set&lt;BR /&gt;
&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002588845.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a002588845.htm&lt;/A&gt;&lt;BR /&gt;
it comes with very useful examples</description>
      <pubDate>Wed, 01 Jun 2011 22:34:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71697#M20710</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-06-01T22:34:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71698#M20711</link>
      <description>[pre]&lt;BR /&gt;
data temp;&lt;BR /&gt;
 infile datalines length=len;&lt;BR /&gt;
 input char_var $varying200. len;&lt;BR /&gt;
datalines4;&lt;BR /&gt;
N:f; j; 33; 52; a; b&lt;BR /&gt;
Y&lt;BR /&gt;
N:g; a; 33; 22; a; b&lt;BR /&gt;
N:f; b; 45; c; a; f&lt;BR /&gt;
N:c; f; 33; 52; a; b&lt;BR /&gt;
N:e; j; 33; 52; a; b&lt;BR /&gt;
N:f; a; e; 52; a; b&lt;BR /&gt;
;;;;&lt;BR /&gt;
run;&lt;BR /&gt;
data op;&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 length pass char $ 8;&lt;BR /&gt;
 pass=scan(strip(char_var),1,' ;:');&lt;BR /&gt;
 i=2;&lt;BR /&gt;
 char=scan(strip(char_var),i,' ;:');&lt;BR /&gt;
 do while(not missing(char));&lt;BR /&gt;
  output;&lt;BR /&gt;
  i+1;&lt;BR /&gt;
  char=scan(strip(char_var),i,' ;:');&lt;BR /&gt;
 end;&lt;BR /&gt;
 drop i char_var;&lt;BR /&gt;
run;&lt;BR /&gt;
proc freq data=op noprint;&lt;BR /&gt;
 tables char / nocum nopercent out=_want(drop=percent);&lt;BR /&gt;
run;&lt;BR /&gt;
data all_chars(keep=char);&lt;BR /&gt;
	length char $ 8;&lt;BR /&gt;
	do i=1 to 71;&lt;BR /&gt;
		char=strip(i);&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	do j= 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j';&lt;BR /&gt;
		char=j;&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=all_chars;&lt;BR /&gt;
 by char;&lt;BR /&gt;
run;&lt;BR /&gt;
options missing=0;&lt;BR /&gt;
data want;&lt;BR /&gt;
 merge all_chars _want;&lt;BR /&gt;
 by char;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
&lt;BR /&gt;
  &lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp

Message was edited by: Ksharp</description>
      <pubDate>Thu, 02 Jun 2011 02:21:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71698#M20711</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-06-02T02:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71699#M20712</link>
      <description>If you would rather use a hash solution as Peter suggested, I came up with the following code.  While it’s a little harder to digest, it’s probably more efficient than my original code.  [pre]&lt;BR /&gt;
data test;&lt;BR /&gt;
input @1 num @4 CHAR_1 $2. @7 CHAR_2 $2. @10 CHAR_3 $2. @13 CHAR_4 $2. @16 CHAR_5 $2. @19 CHAR_6 $2.;&lt;BR /&gt;
DATALINES;&lt;BR /&gt;
1  f  1  33 52 a  b &lt;BR /&gt;
2  Y &lt;BR /&gt;
3  33&lt;BR /&gt;
4  1 &lt;BR /&gt;
5  33 a  b  c &lt;BR /&gt;
6  Y &lt;BR /&gt;
7  18 19 20&lt;BR /&gt;
8  f  33&lt;BR /&gt;
9  a  j&lt;BR /&gt;
10 1  44&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
data counts(keep=char counts);&lt;BR /&gt;
	length char $ 2;&lt;BR /&gt;
	declare hash all_chars(suminc: "count");&lt;BR /&gt;
	all_chars.definekey('char');&lt;BR /&gt;
	all_chars.definedone();&lt;BR /&gt;
	do i=1 to 71;&lt;BR /&gt;
		char=strip(i);&lt;BR /&gt;
		all_chars.add();&lt;BR /&gt;
	end;&lt;BR /&gt;
	do char= 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j';&lt;BR /&gt;
		all_chars.add();&lt;BR /&gt;
	end;&lt;BR /&gt;
	count=1;&lt;BR /&gt;
	do while (not eof);&lt;BR /&gt;
		set test end=eof;&lt;BR /&gt;
		array char_{*} char_:;&lt;BR /&gt;
		do i=1 to dim(char_) while (char_{i} ne '');&lt;BR /&gt;
			char=char_{i};&lt;BR /&gt;
			rc=all_chars.find();&lt;BR /&gt;
		end;&lt;BR /&gt;
	end;&lt;BR /&gt;
	do i=1 to 71;&lt;BR /&gt;
		char=strip(i);&lt;BR /&gt;
		rc=all_chars.sum(sum: counts);&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	do char= 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j';&lt;BR /&gt;
		rc=all_chars.sum(sum: counts);&lt;BR /&gt;
		output;&lt;BR /&gt;
	end;&lt;BR /&gt;
	stop;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
[/pre]</description>
      <pubDate>Thu, 02 Jun 2011 12:24:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71699#M20712</guid>
      <dc:creator>polingjw</dc:creator>
      <dc:date>2011-06-02T12:24:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71700#M20713</link>
      <description>jw&lt;BR /&gt;
 &lt;BR /&gt;
thank you for doing the hard work - I should pay more respect and appreciation&lt;BR /&gt;
I had this simpler implementation in mind for counts of incidence of any characteristic;&lt;BR /&gt;
(assumes a table with ten columns c1 - c10 )&lt;BR /&gt;
data view/view=view ;&lt;BR /&gt;
set orig_data( keep= c1-c10) ;&lt;BR /&gt;
array c(10) ;&lt;BR /&gt;
do i=1 to 10 ;&lt;BR /&gt;
characteristic =  c(i) ;&lt;BR /&gt;
output ;&lt;BR /&gt;
end ;&lt;BR /&gt;
keep characteristic ;&lt;BR /&gt;
run ;&lt;BR /&gt;
proc summary data= view nway ;&lt;BR /&gt;
class characteristic ;&lt;BR /&gt;
output out= counts( drop = _type_ ) ;&lt;BR /&gt;
run ;&lt;BR /&gt;
********************************************************&lt;BR /&gt;
More interesting : I originally thought of multi combinations without rationalising that these will occur in any order and A with X is enough the same as X with A that they sould be counted together. &lt;BR /&gt;
So, assuming 10 (string-type) columns in the data named c1-c10 here is my attempt to count all the combinations that occur;&lt;BR /&gt;
data v2/view=v2 ;&lt;BR /&gt;
set orig_data ;&lt;BR /&gt;
call sortc( of c1-c10 ) ; &lt;BR /&gt;
* that puts the values of the 10 columns into some consistent order ;&lt;BR /&gt;
keep c1-c10 ;&lt;BR /&gt;
run ;&lt;BR /&gt;
proc summary nway data= v2 ; &lt;BR /&gt;
class c1-c10 ;&lt;BR /&gt;
output out= combinations_counted( drop= _type_ );&lt;BR /&gt;
run ;&lt;BR /&gt;
* that provides a table of each combination (of up to 10 characteristics) that occurs in the original data, with _freq_ counting the occurrence;&lt;BR /&gt;
Although some of the combinations wil feature just two characteristics (when c3-c10 will be empty) a full report of two-way combinations probably should count also the occurrence of those two columns within 3-way to 10-way combinations. I find that a bigger challenge to analyse;&lt;BR /&gt;
 &lt;BR /&gt;
regards&lt;BR /&gt;
peterC</description>
      <pubDate>Fri, 03 Jun 2011 14:03:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71700#M20713</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2011-06-03T14:03:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using an ARRAY to count number of records with certain conditions?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71701#M20714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you end up having to use arrays a lot, then this may be a telltail of the data structured less than excellently. Here is one way that does not involve any arrays at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;/* test data */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; one;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; result=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"N:f;1; 3; 52; a; b"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;2&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; result=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"Y"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;3&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; result=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"N:33"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;4&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; result=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"N:1"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id=&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;5&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; result=&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"N:a;b;c"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;/* the 81 tests */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; tests;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; n = &lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;81&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;if&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; n &amp;lt;= &lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;71&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;then&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; test = put(n, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;2.&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;-l);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;else&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; test = substr(&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"abcdefghij"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;, n-&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;71&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; test;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;/* make a long-shaped data */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; long;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; one;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = compress(lowcase(result),&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"0123456789abcdefghij;"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;,&lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;"k"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; passedAll = ifn(missing(result), &lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;, &lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;do&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; point = &lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;1&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;to&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;81&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; tests point=point;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; failedThis = (indexw(trimn(result), trimn(test), &lt;/SPAN&gt;&lt;SPAN style="color: #800080; font-family: Courier New; font-size: 10pt;"&gt;";"&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;)&amp;gt;&lt;/SPAN&gt;&lt;STRONG style="color: #008080; font-size: 10pt; font-family: Courier New;"&gt;0&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; passed = (passedAll or not failedThis);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;output&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;end&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; id test passed;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;/* usage example: count how many people passed each test */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;proc&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;freq&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;=long;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;table&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; test/&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;list&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;missing&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;where&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; passed;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;/* reshape to wide -- it takes just one proc */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;proc&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;transpose&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;=long &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;out&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;=wide(drop=_:) &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;prefix&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;=passed;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;by&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; id;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; passed;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;/* check */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;proc&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;print&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;data&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;=wide;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-family: Courier New; font-size: 10pt;"&gt;var&lt;/SPAN&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt; passed1-passed5;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; font-size: 10pt; font-family: Courier New;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;/* on lst&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; Obs&amp;nbsp;&amp;nbsp;&amp;nbsp; passed1&amp;nbsp;&amp;nbsp;&amp;nbsp; passed2&amp;nbsp;&amp;nbsp;&amp;nbsp; passed3&amp;nbsp;&amp;nbsp;&amp;nbsp; passed4&amp;nbsp;&amp;nbsp;&amp;nbsp; passed5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="color: #008000; font-family: Courier New; font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp; */&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 03 Jun 2011 18:48:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-an-ARRAY-to-count-number-of-records-with-certain/m-p/71701#M20714</guid>
      <dc:creator>chang_y_chung_hotmail_com</dc:creator>
      <dc:date>2011-06-03T18:48:16Z</dc:date>
    </item>
  </channel>
</rss>

