<?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: Multiplication of Corresponding Elements of 2 Datasets in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548472#M8524</link>
    <description>&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Wow - something complicated made simple.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;</description>
    <pubDate>Thu, 04 Apr 2019 12:27:10 GMT</pubDate>
    <dc:creator>jawhitmire</dc:creator>
    <dc:date>2019-04-04T12:27:10Z</dc:date>
    <item>
      <title>Multiplication of Corresponding Elements of 2 Datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548236#M8491</link>
      <description>&lt;P&gt;Version 9.4&amp;nbsp;with no access to library&amp;nbsp;SAS/STATS or IML&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following source code is a condensed version of 2 datasets.&amp;nbsp; Actual data is longer with several decimal places of accuracy.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have1;
	input a b c;
datalines;
5 6 7
8 9 4
3 2 3
;
run;
data work.have2;
	input a b c;
datalines;
4 5 6
2 3 4
9 7 2
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Desired output is product of corresponding elements:&lt;/P&gt;&lt;P&gt;a b c&lt;/P&gt;&lt;P&gt;20 30 42&lt;/P&gt;&lt;P&gt;16 27 16&lt;/P&gt;&lt;P&gt;27 14 6&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The following is the first attempt at coding. It&amp;nbsp;compiles without errors, but contains 6 rows and 3 columns whereas the datasets are appended to one another:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;

create table work.product1 as

select * from work.have1

outer union corr

select * from work.have2; 

quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The following is the second attempt at coding.&amp;nbsp; It compiles without errors, but does not produce the desired results:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp;
	array h1[3,3] /nosymbols;
	array h2[3,3] /nosymbols;
	array product[3,3] ;
	re=read_array('work.have1',h1);
	re=read_array('work.have2',h2);
	call mult(h1,h2,product);
	rc=write_array('work.product',product);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance for your support, insight, and willingness to assist.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sincerely,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 14:53:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548236#M8491</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-04-03T14:53:04Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplication of Corresponding Elements of 2 Datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548239#M8493</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have1;
	input a1 b1 c1;
datalines;
5 6 7
8 9 4
3 2 3
;
run;
data work.have2;
	input a2 b2 c2;
datalines;
4 5 6
2 3 4
9 7 2
;
run;

data want;
    merge have1 have2;
    result_a=a1*a2;
    result_b=b1*b2;
    result_c=c1*c2;
    keep result:;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 03 Apr 2019 15:00:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548239#M8493</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-04-03T15:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplication of Corresponding Elements of 2 Datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548246#M8494</link>
      <description>I especially like the product-matrix, or is it matrix product?, it takes me back to early Computer Science programming exercises in Pascal, C, etc...</description>
      <pubDate>Wed, 03 Apr 2019 15:10:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548246#M8494</guid>
      <dc:creator>ccaulkins9</dc:creator>
      <dc:date>2019-04-03T15:10:43Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplication of Corresponding Elements of 2 Datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548339#M8503</link>
      <description>&lt;P&gt;Thank you for the feedback.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looks like it will be necessary to create additional variable (column) names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No worries, I can do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2019 20:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548339#M8503</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-04-03T20:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplication of Corresponding Elements of 2 Datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548381#M8510</link>
      <description>&lt;P&gt;Assuming that both HAVE1 and HAVE2 have exactly the same variables then here is method that will work without having to know the names of the variables.&lt;/P&gt;
&lt;P&gt;Use a temporary array to hold the values for the first dataset.&lt;/P&gt;
&lt;P&gt;Just make sure to make the temporary array as large or larger than the number of variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want ;
  set have1;
  array x _numeric_;
  array y [1000] _temporary_;
  do _n_=1 to dim(x);
    y[_n_]=x[_n_];
  end;
  set have2;
  do _n_=1 to dim(x);
    x[_n_]=y[_n_]*x[_n_];
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 02:38:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548381#M8510</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-04-04T02:38:22Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplication of Corresponding Elements of 2 Datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548472#M8524</link>
      <description>&lt;P&gt;Tom,&lt;/P&gt;&lt;P&gt;Wow - something complicated made simple.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Jane&lt;/P&gt;</description>
      <pubDate>Thu, 04 Apr 2019 12:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiplication-of-Corresponding-Elements-of-2-Datasets/m-p/548472#M8524</guid>
      <dc:creator>jawhitmire</dc:creator>
      <dc:date>2019-04-04T12:27:10Z</dc:date>
    </item>
  </channel>
</rss>

