<?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: proc freq: accross the dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57733#M16095</link>
    <description>The following should be easy to automate or modify to suit your needs.&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let value_to_match=8.9;&lt;BR /&gt;
&lt;BR /&gt;
proc summary data=SASHELP.CITIDAY(drop=DATE);          *count occurences of each value;         &lt;BR /&gt;
  class _numeric_;&lt;BR /&gt;
  ways 1;&lt;BR /&gt;
  output out=TEST_SUM;&lt;BR /&gt;
run;&lt;BR /&gt;
data TEST_FINAL;                                       *count occurences of a given value;&lt;BR /&gt;
  set TEST_SUM end=LASTOBS;&lt;BR /&gt;
  VALUE=coalesce(of _numeric_);&lt;BR /&gt;
  if abs(sum(VALUE, - &amp;amp;value_to_match))&amp;lt;1e-2 then COUNT+_FREQ_;&lt;BR /&gt;
  if LASTOBS then put "VALUE_TO_MATCH=&amp;amp;value_to_match " COUNT=;&lt;BR /&gt;
run;</description>
    <pubDate>Fri, 24 Jul 2009 01:52:48 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2009-07-24T01:52:48Z</dc:date>
    <item>
      <title>proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57727#M16089</link>
      <description>Hello,&lt;BR /&gt;
&lt;BR /&gt;
Is it possible to get a frequency report across a whole dataset without having the results separated by variables?&lt;BR /&gt;
&lt;BR /&gt;
I have a dataset of roughly 1200 obs and 400 variables and I'd like to know how many cells contain X numerical value. That's it, that's all.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Wed, 22 Jul 2009 19:35:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57727#M16089</guid>
      <dc:creator>halfamazing</dc:creator>
      <dc:date>2009-07-22T19:35:29Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57728#M16090</link>
      <description>This would probably be better done in a data step, where you can count the number of times you encounter a value of X in each row. Then, you can sum up the counts across all rows.</description>
      <pubDate>Wed, 22 Jul 2009 19:37:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57728#M16090</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2009-07-22T19:37:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57729#M16091</link>
      <description>Think you can detail that a bit more? I get the general idea obviously but have no idea where to start when implementing the solution.</description>
      <pubDate>Thu, 23 Jul 2009 13:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57729#M16091</guid>
      <dc:creator>halfamazing</dc:creator>
      <dc:date>2009-07-23T13:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57730#M16092</link>
      <description>Perhaps...&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data have;&lt;BR /&gt;
   input a b c;&lt;BR /&gt;
   cards;&lt;BR /&gt;
1 3 4&lt;BR /&gt;
3 2 1&lt;BR /&gt;
4 5 6&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
data count4;&lt;BR /&gt;
   set have end=eof;&lt;BR /&gt;
   array x&lt;LI&gt; _numeric_;&lt;BR /&gt;
   do _n_ = 1 to dim(x);&lt;BR /&gt;
      count4 + x[_n_] eq 4;&lt;BR /&gt;
      end;&lt;BR /&gt;
   if eof then output;&lt;BR /&gt;
   keep count4;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;/LI&gt;</description>
      <pubDate>Thu, 23 Jul 2009 14:01:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57730#M16092</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-07-23T14:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57731#M16093</link>
      <description>That works very well. Thanks a lot.&lt;BR /&gt;
&lt;BR /&gt;
I have 32 datasets that I need to run this on, is it possible to list all of them and display the results ?&lt;BR /&gt;
&lt;BR /&gt;
dataset1 X&lt;BR /&gt;
dataset2 Y&lt;BR /&gt;
...</description>
      <pubDate>Thu, 23 Jul 2009 16:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57731#M16093</guid>
      <dc:creator>halfamazing</dc:creator>
      <dc:date>2009-07-23T16:59:42Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57732#M16094</link>
      <description>I not sure my example program is going to be the best approach for that.  You’re doling out the specs one a time making it some difficult to understand the ins and outs of your process.&lt;BR /&gt;
&lt;BR /&gt;
How about example data and example output, then you should get better help.</description>
      <pubDate>Thu, 23 Jul 2009 20:17:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57732#M16094</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-07-23T20:17:05Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57733#M16095</link>
      <description>The following should be easy to automate or modify to suit your needs.&lt;BR /&gt;
[pre]&lt;BR /&gt;
%let value_to_match=8.9;&lt;BR /&gt;
&lt;BR /&gt;
proc summary data=SASHELP.CITIDAY(drop=DATE);          *count occurences of each value;         &lt;BR /&gt;
  class _numeric_;&lt;BR /&gt;
  ways 1;&lt;BR /&gt;
  output out=TEST_SUM;&lt;BR /&gt;
run;&lt;BR /&gt;
data TEST_FINAL;                                       *count occurences of a given value;&lt;BR /&gt;
  set TEST_SUM end=LASTOBS;&lt;BR /&gt;
  VALUE=coalesce(of _numeric_);&lt;BR /&gt;
  if abs(sum(VALUE, - &amp;amp;value_to_match))&amp;lt;1e-2 then COUNT+_FREQ_;&lt;BR /&gt;
  if LASTOBS then put "VALUE_TO_MATCH=&amp;amp;value_to_match " COUNT=;&lt;BR /&gt;
run;</description>
      <pubDate>Fri, 24 Jul 2009 01:52:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57733#M16095</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-07-24T01:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57734#M16096</link>
      <description>Can't seem to be able to put all in one reply.&lt;BR /&gt;
&lt;BR /&gt;
Maybe doing it in one go would be possible, depending on how you want to test;&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
data TEST;          &lt;BR /&gt;
  length VALUES $200;&lt;BR /&gt;
  set SASHELP.CITIDAY(drop=DATE) end=LASTOBS;&lt;BR /&gt;
  VALUES=catx(' ',of _numeric_);&lt;BR /&gt;
  COUNT+count(' '||VALUES," &amp;amp;value_to_match ");&lt;BR /&gt;
  if LASTOBS then put "VALUE_TO_MATCH=&amp;amp;value_to_match " COUNT=;&lt;BR /&gt;
run;[/pre]</description>
      <pubDate>Fri, 24 Jul 2009 02:10:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57734#M16096</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-07-24T02:10:02Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57735#M16097</link>
      <description>Well, it does work very well. All I'm trying to do now is either&lt;BR /&gt;
&lt;BR /&gt;
1) Replicate this procedure for each of the 32 datasets I have to count in and merge the outputs to get a total or&lt;BR /&gt;
&lt;BR /&gt;
2) Find a way to count through each of my 32 datasets and get one total for all of them.&lt;BR /&gt;
&lt;BR /&gt;
Any help is appreciated.&lt;BR /&gt;
&lt;BR /&gt;
Thanks.</description>
      <pubDate>Tue, 28 Jul 2009 15:46:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57735#M16097</guid>
      <dc:creator>halfamazing</dc:creator>
      <dc:date>2009-07-28T15:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57736#M16098</link>
      <description>Actually, my problem has evolved.&lt;BR /&gt;
&lt;BR /&gt;
I am running the above code to fetch the number times a particular value appears in a dataset. I would like to produce a report containing the results of this code for 32 different datasets. &lt;BR /&gt;
&lt;BR /&gt;
The report could be in HTML format or Excel and look like the following:&lt;BR /&gt;
&lt;BR /&gt;
ds1    588&lt;BR /&gt;
ds2    122&lt;BR /&gt;
ds3    112&lt;BR /&gt;
...&lt;BR /&gt;
&lt;BR /&gt;
Since I am running this code through a shell in a VB application, it would be easy to loop through the 32 datasets. For that matter, is it possible to extract the count value from each iteration and store it in a variable to display further on? Does anyone see any other possibilities?</description>
      <pubDate>Tue, 28 Jul 2009 19:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57736#M16098</guid>
      <dc:creator>halfamazing</dc:creator>
      <dc:date>2009-07-28T19:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57737#M16099</link>
      <description>If you could put all of your data sets into a single location and issue a LIBNAME on it, then you could do something like the following:&lt;BR /&gt;
&lt;BR /&gt;
%macro count;&lt;BR /&gt;
&lt;BR /&gt;
proc sql noprint;&lt;BR /&gt;
select count(memname) into :table_count separated by '' &lt;BR /&gt;
from dictionary.members where memtype='DATA' and upcase(libname)="&amp;amp;libname";&lt;BR /&gt;
select memname into :table1-:table&amp;amp;table_count&lt;BR /&gt;
from dictionary.members where memtype='DATA' and upcase(libname)="&amp;amp;libname";&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
%do i=1 %to &amp;amp;table_count;&lt;BR /&gt;
&lt;BR /&gt;
%let this_table=&amp;amp;&amp;amp;&amp;amp;table&amp;amp;i;&lt;BR /&gt;
&lt;BR /&gt;
%put NOTE: running matcing count on table &amp;amp;this_table..;&lt;BR /&gt;
&lt;BR /&gt;
data this_count;&lt;BR /&gt;
	set &amp;amp;libname..&amp;amp;this_table end=lastobs;&lt;BR /&gt;
&lt;BR /&gt;
	length table_name $ 32;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
	array _values {*} _numeric_;&lt;BR /&gt;
	do idx=1 to dim(_values);&lt;BR /&gt;
		if abs( _values(idx) - &amp;amp;value_to_match ) le 1e-12 then match_count + 1; &lt;BR /&gt;
	end;&lt;BR /&gt;
&lt;BR /&gt;
	if lastobs then do;&lt;BR /&gt;
		table_name = "&amp;amp;this_table";&lt;BR /&gt;
		output;&lt;BR /&gt;
		end;&lt;BR /&gt;
	keep table_name match_count;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc append base=report new=this_count;&lt;BR /&gt;
run;&lt;BR /&gt;
%end;&lt;BR /&gt;
%mend count;&lt;BR /&gt;
&lt;BR /&gt;
%let value_to_match=0;&lt;BR /&gt;
%let libname=MY_LIBNAME;&lt;BR /&gt;
&lt;BR /&gt;
%count;&lt;BR /&gt;
&lt;BR /&gt;
[revised to remove use of FUZZ]&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: kmg</description>
      <pubDate>Tue, 28 Jul 2009 19:53:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57737#M16099</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-28T19:53:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57738#M16100</link>
      <description>Certainly, you could use macros to loop over all data sets.&lt;BR /&gt;
&lt;BR /&gt;
Since your answer is already stored in a SAS data set, I'm not sure I understand your question: "is it possible to extract the count value from each iteration and store it in a variable to display further on?"</description>
      <pubDate>Tue, 28 Jul 2009 19:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57738#M16100</guid>
      <dc:creator>Paige</dc:creator>
      <dc:date>2009-07-28T19:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57739#M16101</link>
      <description>Opps -- in my prior posting, instead of the function FUZZ, you should compare the absolute difference to a reasonable precision value (as shown in other people's posts), for example, something like:&lt;BR /&gt;
&lt;BR /&gt;
if abs( _values(idx) - &amp;amp;value_to_match ) le 1e-12 then match_count + 1;</description>
      <pubDate>Tue, 28 Jul 2009 19:55:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57739#M16101</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-07-28T19:55:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc freq: accross the dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57740#M16102</link>
      <description>So that mismatches involving missing values are detected, I prefer:&lt;BR /&gt;
&lt;BR /&gt;
if abs(sum( _values(idx), - &amp;amp;value_to_match) ) le 1e-12 then match_count + 1;</description>
      <pubDate>Wed, 29 Jul 2009 06:01:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-freq-accross-the-dataset/m-p/57740#M16102</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2009-07-29T06:01:22Z</dc:date>
    </item>
  </channel>
</rss>

