<?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: Getting product of matrix in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261998#M51068</link>
    <description>Yes well this may be the case however I am trying in data step again and storing it as a function and then run the same to get the product of matrix.</description>
    <pubDate>Thu, 07 Apr 2016 06:14:06 GMT</pubDate>
    <dc:creator>rahul88888</dc:creator>
    <dc:date>2016-04-07T06:14:06Z</dc:date>
    <item>
      <title>Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261608#M50948</link>
      <description>&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;I am getting a wrong result for a bigger matrix however for a small matrix like this i am getting results correctly. Can anybody help me what i may be doing wrong &lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt; test1;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; pol $ prod1-prod9;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;datalines&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;1abc 1 1 0 1 0 0 1 1 0&lt;/P&gt;&lt;P&gt;2abc 0 0 1 1 0 0 1 1 1&lt;/P&gt;&lt;P&gt;3abc 1 1 0 1 0 0 0 0 0&lt;/P&gt;&lt;P&gt;4abc 1 0 1 1 0 0 1 1 0&lt;/P&gt;&lt;P&gt;5abc 0 1 0 1 1 0 0 1 0&lt;/P&gt;&lt;P&gt;6abc 1 1 0 1 0 0 0 0 0&lt;/P&gt;&lt;P&gt;7abc 1 0 1 1 0 0 1 1 0&lt;/P&gt;&lt;P&gt;8abc 0 1 0 1 1 0 0 1 0&lt;/P&gt;&lt;P&gt;9abc 1 1 0 1 0 0 0 0 0&lt;/P&gt;&lt;P&gt;10abc 1 0 1 1 0 0 1 1 0&lt;/P&gt;&lt;P&gt;11abc 0 1 0 1 1 0 0 1 0&lt;/P&gt;&lt;P&gt;12abc 1 1 0 1 0 0 0 0 0&lt;/P&gt;&lt;P&gt;13abc 1 0 1 1 0 0 1 1 0&lt;/P&gt;&lt;P&gt;14abc 0 1 0 1 1 0 0 1 0&lt;/P&gt;&lt;P&gt;15abc 1 1 0 1 0 0 0 0 0&lt;/P&gt;&lt;P&gt;16abc 1 0 1 1 0 0 1 1 0&lt;/P&gt;&lt;P&gt;17abc 0 1 0 1 1 0 0 1 0&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;options&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;mprint&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;mlogic&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;merror&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;symbolgen&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; gen_prod_matrix(ilib,ids,olib,oPds) ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;select num_numeric into :prod_size from dictionary.tables where upcase(memname)=upcase(&amp;amp;ids) and upcase(libname)=upcase(&amp;amp;ilib);&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;SELECT distinct name into :varb_list separated by &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; FROM dictionary.columns where upcase(memname)=upcase(&amp;amp;ids) AND upcase(libname)=upcase(&amp;amp;ilib) and TYPE=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'num'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;SELECT name into :char_var separated by &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;' '&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; FROM dictionary.columns where upcase(memname)=upcase(&amp;amp;ids) AND upcase(libname)=upcase(&amp;amp;ilib) and TYPE=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'char'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;SELECT memname into :ds FROM dictionary.columns where upcase(memname)=upcase(&amp;amp;ids) AND upcase(libname)=upcase(&amp;amp;ilib) and TYPE=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'num'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;SELECT libname into :lib FROM dictionary.columns where upcase(memname)=upcase(&amp;amp;ids) AND upcase(libname)=upcase(&amp;amp;ilib) and TYPE=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'num'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; prod_squ=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;prod_size*&amp;amp;prod_size);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; diag_siz=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;prod_size+1);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/************************************************/&lt;/P&gt;&lt;P&gt;data step1;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;set &amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;lib.&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;ds;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;array prod [&amp;amp;prod_size] &amp;amp;varb_list;&lt;/P&gt;&lt;P&gt;array nmres[&amp;amp;prod_size,&amp;amp;prod_size];&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;do i=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;prod_size;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;do j=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;prod_size;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;val=prod[i]*prod[j];&lt;/P&gt;&lt;P&gt;nmres[i,j]+val;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/*************************************************/&lt;/P&gt;&lt;P&gt;data res1(keep=nmres: key);&lt;/P&gt;&lt;P&gt;set step1 end=last;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;key=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;if last;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/**************************************************/&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;diag&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;prod_squ &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%by&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;diag_siz;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;nmres&amp;amp;i&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; diag_var=%diag ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/****************************************************/&lt;/P&gt;&lt;P&gt;data diagonal;&lt;/P&gt;&lt;P&gt;set res1;&lt;/P&gt;&lt;P&gt;keep &amp;amp;diag_var key;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/************************************************/&lt;/P&gt;&lt;P&gt;data step2(keep=dmres: key);&lt;/P&gt;&lt;P&gt;set diagonal;&lt;/P&gt;&lt;P&gt;array diag[&amp;amp;prod_size] nmres:;&lt;/P&gt;&lt;P&gt;array dmres[&amp;amp;prod_size,&amp;amp;prod_size];&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;do i=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;prod_size;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;do j=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;prod_size;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;dmres[i,j]=sqrt(diag[i])*sqrt(diag[j]);&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;key=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/**********************************************************************/&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table dvd_ds as&lt;/P&gt;&lt;P&gt;select * from res1 t1 inner join step2 t2 on t1.key=t2.key;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;/**********************************************************************/&lt;/P&gt;&lt;P&gt;data res3(keep=res:);&lt;/P&gt;&lt;P&gt;set dvd_ds;&lt;/P&gt;&lt;P&gt;array dm[&amp;amp;prod_squ] dmres:;&lt;/P&gt;&lt;P&gt;array nm[&amp;amp;prod_squ] nmres:;&lt;/P&gt;&lt;P&gt;array res[&amp;amp;prod_squ];&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;do i=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;prod_squ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;res[i]=nm[i]/dm[i];&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/*******************************************************/&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &lt;STRONG&gt;&lt;I&gt;prod&lt;/I&gt;&lt;/STRONG&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%do&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; i=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%to&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; &amp;amp;prod_size;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;prod&amp;amp;i&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%end&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; prod_var=%prod ;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/****************************************************/&lt;/P&gt;&lt;P&gt;data matrix_op(keep=prod:);&lt;/P&gt;&lt;P&gt;set res3;&lt;/P&gt;&lt;P&gt;array results[&amp;amp;prod_squ] res:;&lt;/P&gt;&lt;P&gt;array products[&amp;amp;prod_size] &amp;amp;prod_var;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;arrange=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%eval&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(&amp;amp;prod_size-&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;do i=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;prod_squ by &amp;amp;prod_size;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;do j=i to i+arrange;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;x+&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;products[x]=results[j];&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;x=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/*************************************************************/&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;data &amp;amp;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;OLIB.&lt;STRONG&gt;.&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;&amp;amp;OPDS;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;set matrix_op;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/*******************************************************************/&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%macro&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; colab_filter(in_A =,in_B=,ou_AB=);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/*determine number of rows and columns in the 2nd matrix*/&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; B_id=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(open(&amp;amp;in_B));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; B_rows=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(attrn(&amp;amp;B_id,nobs));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; B_cols=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(attrn(&amp;amp;B_id,nvars));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%let&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; rc=&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;&lt;FONT color="#0000ff" face="Courier New" size="3"&gt;%sysfunc&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;(close(&amp;amp;B_id));&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/*transpose the 2nd matrix*/&lt;/P&gt;&lt;P&gt;proc transpose data=&amp;amp;in_B out=t&amp;amp;in_B(drop=_:);run;&lt;/P&gt;&lt;P&gt;/*making Cartesian product of the 1st and transposed 2nd matrices*/&lt;/P&gt;&lt;P&gt;data &amp;amp;ou_AB;&lt;/P&gt;&lt;P&gt;do until(eofA);&lt;/P&gt;&lt;P&gt;set &amp;amp;in_A end=eofA;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;do i=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to n;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;set t&amp;amp;in_B nobs=n point=i;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;/*multiplication*/&lt;/P&gt;&lt;P&gt;data &amp;amp;ou_AB;&lt;/P&gt;&lt;P&gt;/*new columns for products, equal to number of columns in the 2nd matrix*/&lt;/P&gt;&lt;P&gt;array v[&amp;amp;B_cols];&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;do j=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;B_cols;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;v[j]=&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;0&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;set &amp;amp;ou_AB;&lt;/P&gt;&lt;P&gt;array col _ALL_;&lt;/P&gt;&lt;P&gt;/*multiply corresponding pairs of columns*/&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;do i=&amp;amp;B_cols+&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;2&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt; to &amp;amp;B_cols+&lt;/FONT&gt;&lt;/FONT&gt;&lt;STRONG&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;&lt;FONT color="#008080" face="Courier New" size="3"&gt;1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;+&amp;amp;B_rows;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;v[j]+col[i]*col[i+&amp;amp;B_rows];&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;output;&lt;/P&gt;&lt;P&gt;keep v:;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;FONT color="#000080" face="Courier New" size="3"&gt;&lt;STRONG&gt;%mend&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;/**********************************/&lt;/P&gt;&lt;P&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;%&lt;STRONG&gt;&lt;I&gt;gen_prod_matrix&lt;/I&gt;&lt;/STRONG&gt;(&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'work'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;&lt;FONT color="#800080" face="Courier New" size="3"&gt;'test1'&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;FONT face="Courier New" size="3"&gt;,work,PROD_MATRIX_test1);&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;%&lt;STRONG&gt;&lt;I&gt;colab_filter&lt;/I&gt;&lt;/STRONG&gt;(in_a=test1(DROP=f1:),in_b=PROD_MATRIX_test1,ou_AB=mat_prod_test1);&lt;/P&gt;&lt;P&gt;/**********************************/&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;　&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 06:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261608#M50948</guid>
      <dc:creator>rahul88888</dc:creator>
      <dc:date>2016-04-06T06:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261639#M50957</link>
      <description>&lt;PRE&gt;
If you are talking about Matrix Operator, That is a better question to IML. 
Post it at IML Forum, and Post some data and the output you want, and the logic behind that operator.


&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Apr 2016 09:40:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261639#M50957</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-06T09:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261640#M50958</link>
      <description>&lt;P&gt;Sorry I dont have proc IML i am using SAS 9.2 and it says&lt;/P&gt;&lt;P&gt;ERROR: Bad product ID for procedure IML.&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thats why rather than posting under IML i posted under base SAS and i wanted it to get done without IML. I am trying proc FCMP to create an user difined function hope this works out&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 10:24:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261640#M50958</guid>
      <dc:creator>rahul88888</dc:creator>
      <dc:date>2016-04-06T10:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261648#M50959</link>
      <description>&lt;P&gt;Have you tried&amp;nbsp;the &lt;A href="http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a003193719.htm" target="_blank"&gt;matrix CALL routines&lt;/A&gt; available through PROC FCMP?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Otherwise,&amp;nbsp;I think you should clarify&amp;nbsp;what you are trying to achieve and what exactly goes wrong.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You are talking about "product of matrix." So, you want to implement matrix multiplication in Base SAS?&lt;/LI&gt;
&lt;LI&gt;If this is the case, how does input dataset TEST1 relate to this task? This dataset could be regarded as a 17x9 matrix with an additional character column (POL) of little use, but normally a product involves at least two factors.&lt;/LI&gt;
&lt;LI&gt;You state that&amp;nbsp;"for a small matrix like this i am getting results correctly." However, when I run your code, I get notes "Division by zero detected" and "Mathematical operations could not be performed," which are frowned upon, and a strange matrix with missing values in one row and one column (from the first macro call, %gen_prod_matrix). The second macro call (%colab_filter)&amp;nbsp;fails with an obvious error message about the non-existent variable "f1:" -- I guess that variable POL should be used in the DROP= option.&lt;/LI&gt;
&lt;LI&gt;The code of macro COLAB_FILTER (up to a renamed array) can be found in a &lt;A href="http://stackoverflow.com/questions/22001902/compute-matrix-product-in-base-sas-not-using-iml" target="_blank"&gt;2014 Stackoverflow thread&lt;/A&gt;&amp;nbsp;and is supposed to perform matrix multiplication. So, what's the purpose of macro GEN_PROD_MATRIX?&lt;/LI&gt;
&lt;LI&gt;You wrote that you were "getting a wrong result for a bigger matrix." Why don't you share more details about that "wrong result" (and the expected correct result) with us?&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 10:44:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261648#M50959</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2016-04-06T10:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261659#M50963</link>
      <description>&lt;P&gt;For this matrix the results is correctly displayed across all the outputs however if we increase the number of rows to lets say 50000 or so the results are not correct.&lt;/P&gt;&lt;P&gt;I also checked the matrix code and then found out that the matrix multiplication is not getting dynamic&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 11:25:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261659#M50963</guid>
      <dc:creator>rahul88888</dc:creator>
      <dc:date>2016-04-06T11:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261848#M51030</link>
      <description>&lt;P&gt;I am attaching the excel file and the logic that i am trying to achieve&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Apr 2016 17:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261848#M51030</guid>
      <dc:creator>rahul88888</dc:creator>
      <dc:date>2016-04-06T17:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261961#M51054</link>
      <description>&lt;PRE&gt;
You can run IML code under University Edition. It is totally free.
Can you elaborate How you get Matrix numerator and  denominator ?

&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2016 01:30:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261961#M51054</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-07T01:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261967#M51056</link>
      <description>&lt;P&gt;Numerotor is nothing just the sum of the columns which can be obtained also by proc corr /Cov and creating a daataset for the same&amp;nbsp;&lt;/P&gt;&lt;P&gt;while the dinomintor too is just square root of the combinations of the first matrix&amp;nbsp;&lt;/P&gt;&lt;P&gt;Like Square root for user 1 - it is SQR rooot P1*P1, P1*p2 and so on&lt;/P&gt;</description>
      <pubDate>Thu, 07 Apr 2016 01:46:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261967#M51056</guid>
      <dc:creator>rahul88888</dc:creator>
      <dc:date>2016-04-07T01:46:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261973#M51058</link>
      <description>&lt;PRE&gt;

IML is the best tool for matrix operation.
I really suggest you to use IML code , which is a lot simpler and easier:



proc iml;
x={
1 0 1 1,
0 0 1 1,
0 1 0 1,
1 0 1 0,
1 1 0 0
};

n=ncol(x);
numerator=j(n,n,.);
do i=1 to n;
 do j=1 to n;
  numerator[i,j]=sum(x[,i]#x[,j]);
 end;
end;

vecdiag=vecdiag(numerator);
denominator=j(n,n,.);
do i=1 to n;
 do j=1 to n;
  denominator[i,j]=sqrt(vecdiag[i]#vecdiag[j]);
 end;
end;

divided=numerator/denominator;

Multiplicated=xmult(x,divided);

print numerator ,denominator,divided,Multiplicated;
quit;





&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2016 02:47:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261973#M51058</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-07T02:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261976#M51059</link>
      <description>I wish I had IML I got the error though the array of the first matrix is not becoming dynamic, for some reason will look into the same again. However when I try with fixed product and say let's say for 5 products and fix it Then it works perfectly</description>
      <pubDate>Thu, 07 Apr 2016 02:57:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261976#M51059</guid>
      <dc:creator>rahul88888</dc:creator>
      <dc:date>2016-04-07T02:57:39Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261980#M51061</link>
      <description>&lt;PRE&gt;
I don't know what you are talking about.
If you want read data from table as your sample data. You can do this.
But that lead to ERROR information due to P6 value are all zero , and make Matrix Product meaning nothing.



data test1;
input pol $ prod1-prod9;
datalines;
1abc 1 1 0 1 0 0 1 1 0
2abc 0 0 1 1 0 0 1 1 1
3abc 1 1 0 1 0 0 0 0 0
4abc 1 0 1 1 0 0 1 1 0
5abc 0 1 0 1 1 0 0 1 0
6abc 1 1 0 1 0 0 0 0 0
7abc 1 0 1 1 0 0 1 1 0
8abc 0 1 0 1 1 0 0 1 0
9abc 1 1 0 1 0 0 0 0 0
10abc 1 0 1 1 0 0 1 1 0
11abc 0 1 0 1 1 0 0 1 0
12abc 1 1 0 1 0 0 0 0 0
13abc 1 0 1 1 0 0 1 1 0
14abc 0 1 0 1 1 0 0 1 0
15abc 1 1 0 1 0 0 0 0 0
16abc 1 0 1 1 0 0 1 1 0
17abc 0 1 0 1 1 0 0 1 0
;
run;
proc iml;
use test1;
read all var _num_ into x;
close;

n=ncol(x);
numerator=j(n,n,.);
do i=1 to n;
 do j=1 to n;
  numerator[i,j]=sum(x[,i]#x[,j]);
 end;
end;

vecdiag=vecdiag(numerator);
denominator=j(n,n,.);
do i=1 to n;
 do j=1 to n;
  denominator[i,j]=sqrt(vecdiag[i]#vecdiag[j]);
 end;
end;

divided=numerator/denominator;

Multiplicated=xmult(x,divided);

print numerator ,denominator,divided,Multiplicated;
quit;




OUTPUT:
numerator
11	6	5	11	0	0	6	6	0
6	11	0	11	5	0	1	6	0
5	0	6	6	0	0	6	6	1
11	11	6	17	5	0	7	12	1
0	5	0	5	5	0	0	5	0
0	0	0	0	0	0	0	0	0
6	1	6	7	0	0	7	7	1
6	6	6	12	5	0	7	12	1
0	0	1	1	0	0	1	1	1
denominator
11	11	8.1240384	13.674794	7.4161985	0	8.7749644	11.489125	3.3166248
11	11	8.1240384	13.674794	7.4161985	0	8.7749644	11.489125	3.3166248
8.1240384	8.1240384	6	10.099505	5.4772256	0	6.4807407	8.4852814	2.4494897
13.674794	13.674794	10.099505	17	9.2195445	0	10.908712	14.282857	4.1231056
7.4161985	7.4161985	5.4772256	9.2195445	5	0	5.9160798	7.7459667	2.236068
0	0	0	0	0	0	0	0	0
8.7749644	8.7749644	6.4807407	10.908712	5.9160798	0	7	9.1651514	2.6457513
11.489125	11.489125	8.4852814	14.282857	7.7459667	0	9.1651514	12	3.4641016
3.3166248	3.3166248	2.4494897	4.1231056	2.236068	0	2.6457513	3.4641016	1
divided
1	0.5454545	0.6154575	0.8043997	0	.	0.6837635	0.522233	0
0.5454545	1	0	0.8043997	0.6741999	.	0.1139606	0.522233	0
0.6154575	0	1	0.5940885	0	.	0.9258201	0.7071068	0.4082483
0.8043997	0.8043997	0.5940885	1	0.5423261	.	0.6416889	0.8401681	0.2425356
0	0.6741999	0	0.5423261	1	.	0	0.6454972	0
.	.	.	.	.	.	.	.	.
0.6837635	0.1139606	0.9258201	0.6416889	0	.	1	0.7637626	0.3779645
0.522233	0.522233	0.7071068	0.8401681	0.6454972	.	0.7637626	1	0.2886751
0	0	0.4082483	0.2425356	0	.	0.3779645	0.2886751	1


You notice that P6 are all missing, thus lead to Matrix 'divided' has missing value and can't perform matrix product.
&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2016 03:14:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261980#M51061</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-07T03:14:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261981#M51062</link>
      <description>I accept what you said however I don't have IML on the system then I am working on so will have to try out other ways possible .. I am looking into my code to find the flaws and actually I am trying to get the same answer as you have got . For this dataset my code will work without having to use IML don't know why its failing in a large dataset .. let me try</description>
      <pubDate>Thu, 07 Apr 2016 03:20:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261981#M51062</guid>
      <dc:creator>rahul88888</dc:creator>
      <dc:date>2016-04-07T03:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261982#M51063</link>
      <description>Thanks very much for your patience to look through</description>
      <pubDate>Thu, 07 Apr 2016 03:20:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261982#M51063</guid>
      <dc:creator>rahul88888</dc:creator>
      <dc:date>2016-04-07T03:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261987#M51064</link>
      <description>&lt;PRE&gt;
I am NOT  going to do it by data step. That is a very nasty work.
Maybe that is loss of precision problem.
When you have some very very small value ,that would generate some error value.


Example :

a = 1e13;
b = 1e13;
c = 100 * a;
a = a+1;
x = c || a || b || c;
y = c || a || (-b) || (-c);
z = xmult(x,y`); / * correct answer * /
print z [format=16.0];
wrong = x * y`; / * loss of precision * /
print wrong [format=16.0];
Figure 24.433 Extended-Precision Multiplication
z
20000000000001
wrong
0


&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Apr 2016 03:54:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261987#M51064</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-07T03:54:10Z</dc:date>
    </item>
    <item>
      <title>Re: Getting product of matrix</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261998#M51068</link>
      <description>Yes well this may be the case however I am trying in data step again and storing it as a function and then run the same to get the product of matrix.</description>
      <pubDate>Thu, 07 Apr 2016 06:14:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Getting-product-of-matrix/m-p/261998#M51068</guid>
      <dc:creator>rahul88888</dc:creator>
      <dc:date>2016-04-07T06:14:06Z</dc:date>
    </item>
  </channel>
</rss>

