<?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: Multiply two large datasets in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616998#M18992</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
    use a var {n2 n10};
	read all into a;
	use b var {n2 n10};
	read all into b;
	mult=a#b;
	create out from mult;
	append from mult;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jan 2020 18:26:07 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-01-13T18:26:07Z</dc:date>
    <item>
      <title>Multiply two large datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616984#M18985</link>
      <description>&lt;P&gt;Hello, I would like to multiply two datasets A and B that has equal dimensions T X N which can both can be a large number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- N can be very large (as of 100.000 randomized numbers). The first variable name is equation which is the only variable. Variable name 2:N has numerical name and its not necessarily 1 to 100.000 - it could be 2, 10, 200,... so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Both datasets are similarly structured. They have the same ordering of variable names and observations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- I am currently using SAS 9.4.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example of the two datasets is:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-right lia-quilt-column-main-right"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-right"&gt;&lt;DIV class="lia-message-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;DATASET A&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Variable names &amp;nbsp; &amp;nbsp; Equation &amp;nbsp; &amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 20 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 10&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset B&lt;/P&gt;&lt;P&gt;&amp;nbsp; Variable names &amp;nbsp; &amp;nbsp; Equation &amp;nbsp; &amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;&amp;nbsp;And i wish to get a dataset that has multiplied by elements:&lt;/DIV&gt;&lt;DIV class="lia-rating-metoo lia-component-body"&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dataset want&lt;/P&gt;&lt;P&gt;&amp;nbsp; Variable names &amp;nbsp; &amp;nbsp; Equation &amp;nbsp; &amp;nbsp; 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; 20&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; 10 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp; 3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 5&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 13 Jan 2020 17:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616984#M18985</guid>
      <dc:creator>Tricky</dc:creator>
      <dc:date>2020-01-13T17:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply two large datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616988#M18986</link>
      <description>&lt;P&gt;Do you have PROC IML?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is the data really in SAS? You can't have variable names that are the number 2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm thinking this could be done easily in Microsoft Excel.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 17:46:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616988#M18986</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-13T17:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply two large datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616991#M18988</link>
      <description>&lt;P&gt;I do have proc IML. I believe the variables are written as e.g. '10'n (but its not what comes out when i use proc contents). It could be done in Excel, however dataset A and B change daily so it would be tedious to repeat it in excel. I would rather have a code in SAS&amp;nbsp;&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 17:54:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616991#M18988</guid>
      <dc:creator>Tricky</dc:creator>
      <dc:date>2020-01-13T17:54:34Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply two large datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616996#M18990</link>
      <description>&lt;P&gt;This is sloppy but it should work if your variables are in order:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I added the prefix n to your variables, because like&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;said, you can't start variables with a numeric.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let firstV = n2;
%let lastV = n10;
data a;
Equation = 1; n2 = 0; n10 = 20; output;
Equation = 2; n2 = 10; n10 = 1; output;
Equation = 3; n2 = 5; n10 = 5; output;
run;

data b;
Equation = 1; n2 = 0; n10 = 1; output;
Equation = 2; n2 = 1; n10 = 0; output;
Equation = 3; n2 = 0; n10 = 1; output;
run;

proc sql noprint ;
select cats(name,'=new_',name) into :renames separated by ' '
  from dictionary.columns
  where libname='WORK' and memname='B'
  ;
quit;
 
proc datasets nolist library=work;
  modify b;
    rename &amp;amp;renames;
  run;
quit;

data want (drop=new_Equation i new_&amp;amp;firstV.--new_&amp;amp;lastV.);
merge a b;
array colA{*} &amp;amp;firstV.--&amp;amp;lastV.;
array colB{*} new_&amp;amp;firstV.--new_&amp;amp;lastV.;
do i=1 to dim(colA);
  colA{i} = colA{i}*colB{i};
end;
run;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;just change the first and last variables in the beginning to the first and last in your data.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 18:17:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616996#M18990</guid>
      <dc:creator>JeffMaggio</dc:creator>
      <dc:date>2020-01-13T18:17:37Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply two large datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616997#M18991</link>
      <description>&lt;P&gt;If your datasets are strictly the same size, you could go this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
equation = 1; '2'n = 10; '10'n = 20; output;
equation = 2; '2'n = 15; '10'n = 24; output;
equation = 3; '2'n = 20; '10'n = 40; output;
run;

data b;
equation = 1; '2'n = 1; '10'n = 0; output;
equation = 2; '2'n = 0; '10'n = 1; output;
equation = 3; '2'n = 1; '10'n = 0; output;
run;

proc sql;
select num_numeric into :vars
from dictionary.tables 
where libname="WORK" and memname="A";
quit;

data c;
set a;
array v _numeric_;
array x {&amp;amp;vars.} _temporary_;
do i = 1 to &amp;amp;vars.;
	x{i} = v{i};
	end;
set b;
do i = 2 to &amp;amp;vars.;
	v{i} = v{i}*x{i};
	end;
drop i;
run;

proc print data=c noobs; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE&gt;equation 	2 	10
1 	10 	0
2 	0 	24
3 	20 	0&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jan 2020 18:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616997#M18991</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-01-13T18:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply two large datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616998#M18992</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
    use a var {n2 n10};
	read all into a;
	use b var {n2 n10};
	read all into b;
	mult=a#b;
	create out from mult;
	append from mult;
quit;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 18:26:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/616998#M18992</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-01-13T18:26:07Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply two large datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/617063#M19000</link>
      <description>&lt;P&gt;If&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;The variables to be multiplied comprise all the numeric variables (let's say EQUATION is a character variable), and&lt;/LI&gt;
&lt;LI&gt;They are identically named in A and B&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;then there is a relatively compact way to do this in a DATA step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a b;
  input equation $1. v1 v2 @;   output a;
  input v1 v2;  output b;   
datalines;
1  0 20  0 1
2 10  1  1 0
3  2  5  0 1
run;


data prod;
  set a b;
  by equation;
  array vars _numeric_;
  do over vars;
    vars=vars*lag(vars);
  end;
  if last.equation=1 ;
run;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;OL&gt;
&lt;LI&gt;The SET statement with a BY statement &lt;EM&gt;&lt;STRONG&gt;interleaves&lt;/STRONG&gt;&lt;/EM&gt; observations from A and B.&amp;nbsp; I.e. the equation 1 from A is followed by equation 1 from B, etc, then A2, B2, A3, B3, etc.&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;
&lt;LI&gt;Multiplying vars*lag(vars) effectively produces products of values from A by values from the corresponding B.&amp;nbsp; Just be sure to output only the last record (the "B" record) for each equation.&amp;nbsp; This prevents outputting the A value for one equation multiplied by the B value from the prior equation.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This program assumes that each equation is present in both data sets.&amp;nbsp; But if any equation is present in only one data set, then you have to protect against outputting false results for a single-member equation, contaminated by a lagged value from the prior equation:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data prod;
  set a b;
  by equation;
  array vars _numeric_;
  do over vars;
    vars=vars*lag(vars);
  end;
  if first.equation=1 and last.equation=1 then call missing(of vars{*});
  if last.equation=1 ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;By the way, if equation is also a numeric variable it's relatively straightforward to exclude it from the product calculation (i.e. to exclude if from the array declaration.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2020 21:25:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/617063#M19000</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2020-01-13T21:25:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiply two large datasets</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/617156#M19024</link>
      <description>&lt;P&gt;Cheers - works exactly as intended!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2020 09:11:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Multiply-two-large-datasets/m-p/617156#M19024</guid>
      <dc:creator>Tricky</dc:creator>
      <dc:date>2020-01-14T09:11:37Z</dc:date>
    </item>
  </channel>
</rss>

