<?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 Multiplying Columns in Succession (i.e. multiply AB_3, AB_4, AB_5) in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918280#M83336</link>
    <description>&lt;P&gt;I have a data set:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Path&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;AB_1&lt;/TD&gt;&lt;TD&gt;AB_2&lt;/TD&gt;&lt;TD&gt;AB_3&lt;/TD&gt;&lt;TD&gt;AB_4&lt;/TD&gt;&lt;TD&gt;AB_5&lt;/TD&gt;&lt;TD&gt;AB_6&lt;/TD&gt;&lt;TD&gt;AB_7&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;-1.0&lt;/TD&gt;&lt;TD&gt;23&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;-2.003&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;-13.2&lt;/TD&gt;&lt;TD&gt;-3.08&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;-1.233&lt;/TD&gt;&lt;TD&gt;-1.6&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;13&lt;/TD&gt;&lt;TD&gt;24&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;-2.875&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to set a start number and an end number (i.e. start = 3 and end = 5) such that I can get:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Path&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;AB = AB_3*AB_4*AB_5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;-288.432&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;-9.24&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;-23&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So then if I want to specify start multiplying from AB_4 to AB_7, the code can do it for me.&lt;/P&gt;&lt;P&gt;Currently I'm trying to use a %do loop but I notice that the multiplication operator (*) causes the statement to become a comment:&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;&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;LI-CODE lang="sas"&gt;%macro compound_n_year(start =, end =);
	data AB(keep = path &amp;amp;prov.);
		retain path;
		set data_st;
		
		&amp;amp;prov. = (
					%do i = 0 %to %eval(&amp;amp;end. - &amp;amp;start.);
						%if &amp;amp;i. = 0 %then %do;
							(1+AB_%eval(&amp;amp;start.+&amp;amp;i.))
						%end;
						%else %do;
							*(1+AB_%eval(&amp;amp;start.+&amp;amp;i.))
						%end;
					%end;
				)**12;
	run;
%mend;&lt;/LI-CODE&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;&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;I'm looking into arrays, and notice that there is no "product()" function available to me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an alternative way for me to implement the function?&lt;/P&gt;&lt;P&gt;I believe proc iml is not available to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Wed, 28 Feb 2024 19:48:49 GMT</pubDate>
    <dc:creator>yellowAve</dc:creator>
    <dc:date>2024-02-28T19:48:49Z</dc:date>
    <item>
      <title>Multiplying Columns in Succession (i.e. multiply AB_3, AB_4, AB_5)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918280#M83336</link>
      <description>&lt;P&gt;I have a data set:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;Path&lt;/P&gt;&lt;/TD&gt;&lt;TD&gt;AB_1&lt;/TD&gt;&lt;TD&gt;AB_2&lt;/TD&gt;&lt;TD&gt;AB_3&lt;/TD&gt;&lt;TD&gt;AB_4&lt;/TD&gt;&lt;TD&gt;AB_5&lt;/TD&gt;&lt;TD&gt;AB_6&lt;/TD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lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;-23&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So then if I want to specify start multiplying from AB_4 to AB_7, the code can do it for me.&lt;/P&gt;&lt;P&gt;Currently I'm trying to use a %do loop but I notice that the multiplication operator (*) causes the statement to become a comment:&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;&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;LI-CODE lang="sas"&gt;%macro compound_n_year(start =, end =);
	data AB(keep = path &amp;amp;prov.);
		retain path;
		set data_st;
		
		&amp;amp;prov. = (
					%do i = 0 %to %eval(&amp;amp;end. - &amp;amp;start.);
						%if &amp;amp;i. = 0 %then %do;
							(1+AB_%eval(&amp;amp;start.+&amp;amp;i.))
						%end;
						%else %do;
							*(1+AB_%eval(&amp;amp;start.+&amp;amp;i.))
						%end;
					%end;
				)**12;
	run;
%mend;&lt;/LI-CODE&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;&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;I'm looking into arrays, and notice that there is no "product()" function available to me.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there an alternative way for me to implement the function?&lt;/P&gt;&lt;P&gt;I believe proc iml is not available to me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 19:48:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918280#M83336</guid>
      <dc:creator>yellowAve</dc:creator>
      <dc:date>2024-02-28T19:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying Columns in Succession (i.e. multiply AB_3, AB_4, AB_5)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918290#M83337</link>
      <description>&lt;P&gt;I think that you need to provide a bit more details of what you want to do in other cases. Is this always going to be the product of 3 numbers? Will they always be sequential columns? And if you are doing multiple start/end what the output set is supposed to look like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since your code includes the words COMPOUND and a suspicious possible 12 month value, I might suggest providing a description of exactly what this is supposed to calculate. If it is a financial calculation you might be reinventing the wheel as there are a large number of financial functions in SAS and many of them take direct lists of variables. Which would make arrays the better approach.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 18:45:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918290#M83337</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-02-28T18:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying Columns in Succession (i.e. multiply AB_3, AB_4, AB_5)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918291#M83338</link>
      <description>&lt;P&gt;I plan to specify the start column and the end column.&lt;/P&gt;&lt;P&gt;So I can specify 1 and 7, and the code would multiply columns 1 to 7 for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It can also be 4 to 6, or 3 to 50, it doesn't matter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes this is applied in a financial setting,&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 18:54:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918291#M83338</guid>
      <dc:creator>yellowAve</dc:creator>
      <dc:date>2024-02-28T18:54:30Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying Columns in Succession (i.e. multiply AB_3, AB_4, AB_5)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918299#M83339</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/457561"&gt;@yellowAve&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For non-negative &lt;FONT face="courier new,courier"&gt;AB_&lt;EM&gt;n&lt;/EM&gt;&lt;/FONT&gt; values you can use&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;AB=geomean(of AB_3-AB_5)**n(of AB_3-AB_5);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2024 19:27:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918299#M83339</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2024-02-28T19:27:35Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying Columns in Succession (i.e. multiply AB_3, AB_4, AB_5)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918302#M83340</link>
      <description>&lt;P&gt;They can be negative decimals as well.&lt;/P&gt;&lt;P&gt;Sorry for not specifying, I've updated the original post too.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 19:49:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918302#M83340</guid>
      <dc:creator>yellowAve</dc:creator>
      <dc:date>2024-02-28T19:49:48Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying Columns in Succession (i.e. multiply AB_3, AB_4, AB_5)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918306#M83341</link>
      <description>&lt;P&gt;So if you just want to use a single start/stop pair at a time then your approach should work.&amp;nbsp; Just simplify it.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro mult(start,end);
%local i sep;
%do i=&amp;amp;start %to &amp;amp;end;
  &amp;amp;sep AB_&amp;amp;i
  %let sep=*;
%end;
%mend mult;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Let's try it out:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;options mprint;
data test;
 input ab_1 ab_2 ab_3 ;
 ab=%mult(1,3);
cards;
1 2 3
2 3 4
1 2 1
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Result&lt;/P&gt;
&lt;PRE&gt;Obs    ab_1    ab_2    ab_3    ab

 1       1       2       3      6
 2       2       3       4     24
 3       1       2       1      2
&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Feb 2024 20:05:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918306#M83341</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2024-02-28T20:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying Columns in Succession (i.e. multiply AB_3, AB_4, AB_5)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918313#M83342</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/457561"&gt;@yellowAve&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I plan to specify the start column and the end column.&lt;/P&gt;
&lt;P&gt;So I can specify 1 and 7, and the code would multiply columns 1 to 7 for me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It can also be 4 to 6, or 3 to 50, it doesn't matter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yes this is applied in a financial setting,&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;And what financial calculation is this? The FINANCE function all by itself has 50+ calculations available. And there are another 30+ financial related functions.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2024 20:16:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918313#M83342</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-02-28T20:16:09Z</dc:date>
    </item>
    <item>
      <title>Re: Multiplying Columns in Succession (i.e. multiply AB_3, AB_4, AB_5)</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918324#M83343</link>
      <description>Thank you!</description>
      <pubDate>Wed, 28 Feb 2024 20:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Multiplying-Columns-in-Succession-i-e-multiply-AB-3-AB-4-AB-5/m-p/918324#M83343</guid>
      <dc:creator>yellowAve</dc:creator>
      <dc:date>2024-02-28T20:41:58Z</dc:date>
    </item>
  </channel>
</rss>

