<?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: freq. of records in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68314#M19561</link>
    <description>Hi Proc Me,&lt;BR /&gt;
I have submited the following code &lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table brookfr &lt;BR /&gt;
as &lt;BR /&gt;
select lname, pcode, fname,sum(brfr.beatles1) as bbeat,sum(brfr.bmalone1) as bmalone,&lt;BR /&gt;
sum(brfr.bombedout1) as bombout,sum(brfr.confusions1) as confuse,sum(brfr.daveorch1)as dave&lt;BR /&gt;
from &lt;BR /&gt;
(&lt;BR /&gt;
select lname,pcode,fname,count(*) as bbeat,0 as bmalone, 0 as bombout,0 as confuse,0 as dave&lt;BR /&gt;
from brfr.bbeatles1&lt;BR /&gt;
group by lname, pcode, fname&lt;BR /&gt;
union &lt;BR /&gt;
select lname,pcode,fname,0 as bbeat,count(*) as bmalone,0 as bombout,0 as confuse,0 as dave&lt;BR /&gt;
from brfr.bmalone1&lt;BR /&gt;
group by lname, pcode, fname &lt;BR /&gt;
union&lt;BR /&gt;
select lname,pcode,fname,0 as bbeat,0 as bmalone, count(*) as bombout,0 as confuse,0 as dave&lt;BR /&gt;
from brfr.bombedout1&lt;BR /&gt;
group by lname,pcode,fname&lt;BR /&gt;
union &lt;BR /&gt;
select lname,pcode,fname,0 as bbeat,0 as bmalone,0 as bombout,count(*) as confuse,0 as dave&lt;BR /&gt;
from brfr.confusions1&lt;BR /&gt;
group by lname,pcode,fname&lt;BR /&gt;
union&lt;BR /&gt;
select lname,pcode,fname,0 as bbeat,0 as bmalone,0 as bombedout,0 as confuse,count(*) as dave&lt;BR /&gt;
from brfr.daveorch1&lt;BR /&gt;
group by lname,pcode,fname&lt;BR /&gt;
)&lt;BR /&gt;
group by lname,pcode,fname&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
AND I AM GETTING THE FOLLOWING ERROR&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.</description>
    <pubDate>Fri, 09 Jan 2009 09:16:18 GMT</pubDate>
    <dc:creator>ssas</dc:creator>
    <dc:date>2009-01-09T09:16:18Z</dc:date>
    <item>
      <title>freq. of records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68309#M19556</link>
      <description>Hi Can any one help,&lt;BR /&gt;
 I got 2 queries.&lt;BR /&gt;
1.	I have table like the following.&lt;BR /&gt;
I would like to find out the frequency of (Same) records with in the table with respect to their lname postcode fname.&lt;BR /&gt;
&lt;BR /&gt;
Table- A1&lt;BR /&gt;
fname	lname	pcode&lt;BR /&gt;
Amer	George	Dd4 5st&lt;BR /&gt;
Paul	George	Dd4 5st&lt;BR /&gt;
Amer	collin	Dd4 5st&lt;BR /&gt;
Amer	George	Dd5 6st&lt;BR /&gt;
AJ	BENNISON	ME20 6JE&lt;BR /&gt;
G B	BOWEN	ME5 8QR&lt;BR /&gt;
L	BRYANS	ME7 1RB&lt;BR /&gt;
M	CAIN	ME7 4EH&lt;BR /&gt;
P	CHAMBERS	ME19 5QB&lt;BR /&gt;
J	CHAMPION	ME3 9RE&lt;BR /&gt;
Amer	George	Dd4 5st&lt;BR /&gt;
FW	CORDIER	ME4 4XJ&lt;BR /&gt;
M	COUSENS	ME8 9QS&lt;BR /&gt;
L	COUSIN	ME5 7JY&lt;BR /&gt;
Amer	collin	Dd4 5st&lt;BR /&gt;
H	DAVIES	RH12 1PX&lt;BR /&gt;
P	DEEPROSE	ME7 5QG&lt;BR /&gt;
Amer	George	Dd5 6st&lt;BR /&gt;
D	GOVIER	ME7 2UX&lt;BR /&gt;
JACQ	GRAY	ME8 9QZ&lt;BR /&gt;
JK	GRIFFIN	CT7 9RX&lt;BR /&gt;
J	GRIFFIN	ME2 2SY&lt;BR /&gt;
&lt;BR /&gt;
output should like:&lt;BR /&gt;
&lt;BR /&gt;
fname  lname  pcode  no. of times&lt;BR /&gt;
alan   john       me4 5sd   2&lt;BR /&gt;
ban   dadkds   mf3 7ds    1&lt;BR /&gt;
dad   fdsfd      bg3 5fd      4 &lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
2.	I have the 30 tables ( a1 to a30) like above A1  and I want to find out the how many records are in common,  which records in which table and howmany timeswith respect to their lname, pcode, fname.&lt;BR /&gt;
 Output should look like &lt;BR /&gt;
&lt;BR /&gt;
Fname 	Lname	Pcode	Freq.	Tables&lt;BR /&gt;
Amer	George	Dd4 5st	2	A5,a10&lt;BR /&gt;
Paul	George	Dd4 5st	4	A3,a6,a9,a15&lt;BR /&gt;
Amer	collin	Dd4 5st	1	A25&lt;BR /&gt;
Amer	George	Dd5 6st	3	A17,a22,a26&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Thanks in advance,&lt;BR /&gt;
sams</description>
      <pubDate>Thu, 08 Jan 2009 09:57:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68309#M19556</guid>
      <dc:creator>ssas</dc:creator>
      <dc:date>2009-01-08T09:57:32Z</dc:date>
    </item>
    <item>
      <title>Re: freq. of records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68310#M19557</link>
      <description>1[pre]&lt;BR /&gt;
  PROC summary nway data= A1 ;&lt;BR /&gt;
    class fname lname pcode ;&lt;BR /&gt;
    output  ;&lt;BR /&gt;
  run;&lt;BR /&gt;
proc print ;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
will create the summary counts for "A1" in a default work data set.&lt;BR /&gt;
&lt;BR /&gt;
2&lt;BR /&gt;
You would want to loop through all your tables. &lt;BR /&gt;
Assuming that in your libname SAMS, these tables are the only ones with names beginning "ABC", then you can use a dictionary table to generate the code above for each ABCxxx table. (see below).&lt;BR /&gt;
Collecting all these together is (imho) best done with proc append as each summary is created, but first needs the table name to be added to results[pre]&lt;BR /&gt;
 data ;&lt;BR /&gt;
    length table $32;&lt;BR /&gt;
    retain table "ABC1" ;&lt;BR /&gt;
    set ; * picking up latest results;&lt;BR /&gt;
 run;&lt;BR /&gt;
* then collecting results is just code like;&lt;BR /&gt;
  proc append base= collection ;&lt;BR /&gt;
  run ;[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
Generating this code for every ABCxx data set in SAMS library needs a loop which can be provided in a data step reading dictionary.tables through view SASHELP.vTable and using  CALL EXECUTE() to push the code to run.&lt;BR /&gt;
Here is that packaging of the code generation[pre]* first ensure the "collection" is empty ;&lt;BR /&gt;
proc delete data= collection; &lt;BR /&gt;
run;&lt;BR /&gt;
* now loop through the data sets ; &lt;BR /&gt;
data _null_ ;&lt;BR /&gt;
  set sashelp.vtable ;  * look through _ALL_ datasets known to SAS session;&lt;BR /&gt;
  where libname = 'SAMS' ;  * use only those in libname SAMS ;&lt;BR /&gt;
  where also memname =: 'ABC' ;  * and only tables beginning ABC ;&lt;BR /&gt;
  * now generate summary code ;&lt;BR /&gt;
  call execute( 'proc summary nway missing data=SAMS.' !! memname );&lt;BR /&gt;
  call execute( '  ; class  fname lname pcode ; output ; run;'  );&lt;BR /&gt;
  * now add table name to results ;&lt;BR /&gt;
  call execute( 'data ; length table $32; retain table ' );&lt;BR /&gt;
  call execute( quote( trim( memname )) );&lt;BR /&gt;
  call execute( ' ; set ; run; ' ) ;&lt;BR /&gt;
  * now append to collection ;&lt;BR /&gt;
  call execute( 'proc append base= collection; run; ' );&lt;BR /&gt;
run;[/pre]&lt;BR /&gt;
After that has run, you will have a dataset called collection holding the counts you need in column _FREQ_ .&lt;BR /&gt;
I think PROC TABULATE provides the neatest way to show the matrix with column for each table and a row for each combination of the class variables Fname, lName, and pCode. &lt;BR /&gt;
To handle the multiple columns, use ODS destination html or if excel is suitable, use ods destination tagsets.excelxp. For simplicity, here is the html[pre]ods html file='column combination analysis.html' ;&lt;BR /&gt;
ods listing close ;&lt;BR /&gt;
proc tabulate data= collection missing noseps ;&lt;BR /&gt;
   class  table fname lname pcode ;&lt;BR /&gt;
   var    _freq_ ;&lt;BR /&gt;
   table  ( all fname*lname*pcode all ), _freq_=' '*sum=' '*f= comma8.&lt;BR /&gt;
          * ( all = 'all tables'  table=' '  all = 'all tables' )&lt;BR /&gt;
        / rts= 30 ;&lt;BR /&gt;
run;&lt;BR /&gt;
ods _all_ close ;[/pre]&lt;BR /&gt;
Of course ODS provides many ways of improving the presentation, but I think nothing is as convenient as PROC TABULATE for preparing this content.&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Thu, 08 Jan 2009 11:16:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68310#M19557</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-08T11:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: freq. of records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68311#M19558</link>
      <description>Thanks for your reply, &lt;BR /&gt;
For easy understanding i mentioned a1 to a30, but they have different names.&lt;BR /&gt;
Each table represents sitename.&lt;BR /&gt;
could you please give detailed code or explanation.</description>
      <pubDate>Thu, 08 Jan 2009 14:24:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68311#M19558</guid>
      <dc:creator>ssas</dc:creator>
      <dc:date>2009-01-08T14:24:49Z</dc:date>
    </item>
    <item>
      <title>Re: freq. of records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68312#M19559</link>
      <description>An SQL based way of doing this would be:&lt;BR /&gt;
&lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table want&lt;BR /&gt;
as&lt;BR /&gt;
select lname, postcode, fname, sum(london) as london, sum(paris) as paris, sum(ny) as ny&lt;BR /&gt;
from &lt;BR /&gt;
(&lt;BR /&gt;
select lname, postcode, fname, count(*) as london, 0 as paris, 0 as ny&lt;BR /&gt;
from london&lt;BR /&gt;
group by lname, postcode, fname&lt;BR /&gt;
union &lt;BR /&gt;
select lname, postcode, fname, 0 as london, count(*) as paris, 0 as ny&lt;BR /&gt;
from paris&lt;BR /&gt;
group by lname, postcode, fname&lt;BR /&gt;
union&lt;BR /&gt;
select lname, postcode, fname, 0 as london, 0 as paris, count(*) as ny&lt;BR /&gt;
from ny&lt;BR /&gt;
group by lname, postcode, fname&lt;BR /&gt;
)&lt;BR /&gt;
group by lname, postcode, fname&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
This won't be especially fast, but is easy to code and, I hope, intuitive to understand.&lt;BR /&gt;
&lt;BR /&gt;
ProcMe

ProcMe: typo, missed the last from&lt;BR /&gt;
&lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: ProcMe</description>
      <pubDate>Thu, 08 Jan 2009 15:11:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68312#M19559</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-08T15:11:39Z</dc:date>
    </item>
    <item>
      <title>Re: freq. of records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68313#M19560</link>
      <description>if you want to buy product I'll be happy to provide</description>
      <pubDate>Thu, 08 Jan 2009 16:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68313#M19560</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-08T16:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: freq. of records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68314#M19561</link>
      <description>Hi Proc Me,&lt;BR /&gt;
I have submited the following code &lt;BR /&gt;
proc sql;&lt;BR /&gt;
create table brookfr &lt;BR /&gt;
as &lt;BR /&gt;
select lname, pcode, fname,sum(brfr.beatles1) as bbeat,sum(brfr.bmalone1) as bmalone,&lt;BR /&gt;
sum(brfr.bombedout1) as bombout,sum(brfr.confusions1) as confuse,sum(brfr.daveorch1)as dave&lt;BR /&gt;
from &lt;BR /&gt;
(&lt;BR /&gt;
select lname,pcode,fname,count(*) as bbeat,0 as bmalone, 0 as bombout,0 as confuse,0 as dave&lt;BR /&gt;
from brfr.bbeatles1&lt;BR /&gt;
group by lname, pcode, fname&lt;BR /&gt;
union &lt;BR /&gt;
select lname,pcode,fname,0 as bbeat,count(*) as bmalone,0 as bombout,0 as confuse,0 as dave&lt;BR /&gt;
from brfr.bmalone1&lt;BR /&gt;
group by lname, pcode, fname &lt;BR /&gt;
union&lt;BR /&gt;
select lname,pcode,fname,0 as bbeat,0 as bmalone, count(*) as bombout,0 as confuse,0 as dave&lt;BR /&gt;
from brfr.bombedout1&lt;BR /&gt;
group by lname,pcode,fname&lt;BR /&gt;
union &lt;BR /&gt;
select lname,pcode,fname,0 as bbeat,0 as bmalone,0 as bombout,count(*) as confuse,0 as dave&lt;BR /&gt;
from brfr.confusions1&lt;BR /&gt;
group by lname,pcode,fname&lt;BR /&gt;
union&lt;BR /&gt;
select lname,pcode,fname,0 as bbeat,0 as bmalone,0 as bombedout,0 as confuse,count(*) as dave&lt;BR /&gt;
from brfr.daveorch1&lt;BR /&gt;
group by lname,pcode,fname&lt;BR /&gt;
)&lt;BR /&gt;
group by lname,pcode,fname&lt;BR /&gt;
;&lt;BR /&gt;
quit;&lt;BR /&gt;
&lt;BR /&gt;
AND I AM GETTING THE FOLLOWING ERROR&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
&lt;BR /&gt;
look_ds: what's on FROM clause?&lt;BR /&gt;
ERROR: Unresolved reference to table/correlation name brfr.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.&lt;BR /&gt;
ERROR: The SUM summary function requires a numeric argument.</description>
      <pubDate>Fri, 09 Jan 2009 09:16:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68314#M19561</guid>
      <dc:creator>ssas</dc:creator>
      <dc:date>2009-01-09T09:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: freq. of records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68315#M19562</link>
      <description>In the surrounding query (where you have sum(bfr.xxxxx) you cannot refer to bfr, the column will refer to the result of the inner query, which does not cary any bale name, or alias. So remove bfr. in the outer query, or add an alias bfr after the from (....) .&lt;BR /&gt;
&lt;BR /&gt;
/Linus</description>
      <pubDate>Fri, 09 Jan 2009 11:25:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68315#M19562</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2009-01-09T11:25:59Z</dc:date>
    </item>
    <item>
      <title>Re: freq. of records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68316#M19563</link>
      <description>Hi Mates,&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help. I got the required output except the total.&lt;BR /&gt;
i mean total of 0 and 1's of the every record.&lt;BR /&gt;
for ex:&lt;BR /&gt;
fname lname pcode  total   a1 a2 a3 a4....&lt;BR /&gt;
&lt;BR /&gt;
jhon alex  dg3 8fs  2     0 1 0 1 0 0 0&lt;BR /&gt;
&lt;BR /&gt;
If it also resolved i will be very happy.&lt;BR /&gt;
&lt;BR /&gt;
Thanks &amp;amp; Regards,&lt;BR /&gt;
sams</description>
      <pubDate>Mon, 12 Jan 2009 12:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68316#M19563</guid>
      <dc:creator>ssas</dc:creator>
      <dc:date>2009-01-12T12:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: freq. of records</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68317#M19564</link>
      <description>have I understood this&lt;BR /&gt;
You require:&lt;BR /&gt;
  {class,combinations}, total freq, {freq, in each table}&lt;BR /&gt;
Adapting the call execute() approach with&lt;BR /&gt;
1 use a table of table-names to be investigated&lt;BR /&gt;
2 build summary for each table across the class combinations&lt;BR /&gt;
3 for each class combination: merge into a "collection" table of results, the freq of the class-combination in that original table, and add its _freq_ to the overall total freq.&lt;BR /&gt;
 &lt;BR /&gt;
Here is some code which also generates test data[pre]** first build the list of data sets ; &lt;BR /&gt;
data these_data_sets ;&lt;BR /&gt;
  informat memname $upcase32. ;&lt;BR /&gt;
  input memname ;&lt;BR /&gt;
datalines ;&lt;BR /&gt;
london&lt;BR /&gt;
paris&lt;BR /&gt;
new_York&lt;BR /&gt;
;[/pre]and as test data for demo, create these datasets in SAMS which has the same path as WORK;[pre]libname sams (work) ;&lt;BR /&gt;
data london;&lt;BR /&gt;
  input fname $ lname $ pcode &amp;amp; $ ;&lt;BR /&gt;
cards ; &lt;BR /&gt;
Amer George Dd4 5st&lt;BR /&gt;
Paul George Dd4 5st&lt;BR /&gt;
Amer collin Dd4 5st&lt;BR /&gt;
Amer George Dd5 6st&lt;BR /&gt;
AJ BENNISON ME20 6JE&lt;BR /&gt;
; &lt;BR /&gt;
data paris;&lt;BR /&gt;
  input fname $ lname $ pcode &amp;amp; $ ;&lt;BR /&gt;
cards ; &lt;BR /&gt;
Amer George Dd4 5st&lt;BR /&gt;
Amer George Dd4 5st&lt;BR /&gt;
Paul George Dd4 5st&lt;BR /&gt;
Amer collin Dd4 5st&lt;BR /&gt;
Amer George Dd5 6st&lt;BR /&gt;
AJ BENNISON ME20 6JE&lt;BR /&gt;
; &lt;BR /&gt;
data new_York ;&lt;BR /&gt;
 input fname $ lname $ pcode &amp;amp; $ ;&lt;BR /&gt;
cards ; &lt;BR /&gt;
Amer collin Dd4 5st&lt;BR /&gt;
H DAVIES RH12 1PX&lt;BR /&gt;
P DEEPROSE ME7 5QG&lt;BR /&gt;
Amer George Dd5 6st&lt;BR /&gt;
D GOVIER ME7 2UX&lt;BR /&gt;
;[/pre]&lt;BR /&gt;
* next ensure the "collection" is empty before merging ;[pre]data  collection;&lt;BR /&gt;
  retain fname lname pcode freq ;&lt;BR /&gt;
  length fname lname pcode $32 freq 8 ;&lt;BR /&gt;
  stop ; &lt;BR /&gt;
run;[/pre]&lt;BR /&gt;
* Generating summary code for every data set in SAMS library named in table these_data_sets needs a loop reading that table these_data_sets and using CALL EXECUTE() to push the code to run.&lt;BR /&gt;
Here is that packaging of the code generation. Next loop through the data sets ; [pre]data _null_ ;&lt;BR /&gt;
  set these_data_sets( keep= memname ) ;  * look through _ALL_ required datasets ;&lt;BR /&gt;
  * now generate summary code ;&lt;BR /&gt;
  call execute( 'proc summary nway missing data=SAMS.' !! memname );&lt;BR /&gt;
  call execute( '  ; class  fname lname pcode ; output out= a; run;'  );&lt;BR /&gt;
  * now merge into the collection ;&lt;BR /&gt;
  call execute( ' data collection ;' );&lt;BR /&gt;
  call execute( '   merge collection( in= _base)  a( in= newbits     ' );&lt;BR /&gt;
  call execute( '                       keep= fname lname pcode _freq_      ' ); &lt;BR /&gt;
  call execute( '                     rename= ( _freq_ =' !! memname !! ' ));' );&lt;BR /&gt;
  call execute( '      by fname lname pcode ;       ' );&lt;BR /&gt;
  call execute( '   if newbits then freq =sum(  freq, ' !! memname !! ' ); ' );&lt;BR /&gt;
  call execute( ' run ; ' );&lt;BR /&gt;
run ;[/pre] * finally report results;[pre]proc print n; sum _numeric_; run;[/pre] &lt;BR /&gt;
&lt;BR /&gt;
I think that produces what is required.&lt;BR /&gt;
Run it and see how much clearer it becomes when you can read the log with everything in order.&lt;BR /&gt;
Here is the output I got from testing[pre]The SAS System                                                   20:27 Wednesday, January 14, 2009 &lt;BR /&gt;
&lt;BR /&gt;
Obs    fname     lname       pcode      freq    LONDON    PARIS    NEW_YORK&lt;BR /&gt;
&lt;BR /&gt;
 1     AJ       BENNISON    ME20 6JE      2        1        1          .&lt;BR /&gt;
 2     Amer     George      Dd4 5st       3        1        2          .&lt;BR /&gt;
 3     Amer     George      Dd5 6st       3        1        1          1&lt;BR /&gt;
 4     Amer     collin      Dd4 5st       3        1        1          1&lt;BR /&gt;
 5     D        GOVIER      ME7 2UX       1        .        .          1&lt;BR /&gt;
 6     H        DAVIES      RH12 1PX      1        .        .          1&lt;BR /&gt;
 7     P        DEEPROSE    ME7 5QG       1        .        .          1&lt;BR /&gt;
 8     Paul     George      Dd4 5st       2        1        1          .&lt;BR /&gt;
                                        ====    ======    =====    ========&lt;BR /&gt;
                                         16        5        6          5&lt;BR /&gt;
&lt;BR /&gt;
N = 8[/pre]&lt;BR /&gt;
&lt;BR /&gt;
PeterC</description>
      <pubDate>Wed, 14 Jan 2009 21:48:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/freq-of-records/m-p/68317#M19564</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-01-14T21:48:36Z</dc:date>
    </item>
  </channel>
</rss>

