<?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: Mean Calculation in Data Step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466148#M118926</link>
    <description>&lt;P&gt;First you need to explain what you are doing, and why you are doing it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If nothing else, you could use CALL SYMPUTX in the data step to assign values to macro variables, and then you don't run into the problem you had with using an asterisk.&lt;/P&gt;</description>
    <pubDate>Wed, 30 May 2018 17:49:24 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2018-05-30T17:49:24Z</dc:date>
    <item>
      <title>Mean Calculation in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466136#M118919</link>
      <description>&lt;P&gt;All,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;I am trying to write a simple macro. The code is provided below and I would like to seek your help on what I could be doing wrong.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;%Macro Test(a,b,c,d,e,f); 

%Put &amp;amp;a; 
%Put &amp;amp;b; 
%Put &amp;amp;c; 
%Put &amp;amp;d;
%Put &amp;amp;e; 
%Put &amp;amp;f; 

Data _Null_;
	%Let Avg1 = Mean(&amp;amp;a,&amp;amp;b);
	 
	%Put &amp;amp;Avg1; 
	
	%Let Avg2 = Mean(&amp;amp;c,&amp;amp;d);
	
	%Put &amp;amp;Avg2; 
	
	%Let Res = (&amp;amp;Avg1 * &amp;amp;e) + (&amp;amp;Avg2 * &amp;amp;f); /* Code fails Here */ 
	
	&amp;amp;Res;
RUN;

%MEND;  

%Test(0.050,0.025,0.03,0.40,0.93,0.25);&lt;/PRE&gt;&lt;P&gt;Wonder what is tripping it. Would appreciate your guidance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:12:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466136#M118919</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-05-30T17:12:50Z</dc:date>
    </item>
    <item>
      <title>Re: Mean Calculation in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466138#M118920</link>
      <description>&lt;P&gt;It's not clear what you want for a final result. Do you want Res printed to the log or stored in a macro?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At any rate, think if the macro language as a "template" that enables you to write SAS code. As a beginner, start by writing the SAS code that you want, then use %LET statements to replace hard-coded values with macro values, and finally use the %MACRO and %MEND statements to encapsulate the logic.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The following statements print the result of Res to the log. You can use SYMPUT or SYMPUTX if you need that value in a macro variable.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Macro Test(a,b,c,d,e,f); 
Data _Null_;
	Avg1 = Mean(&amp;amp;a,&amp;amp;b);
   Avg2 = Mean(&amp;amp;c,&amp;amp;d);
   Res = (Avg1 * &amp;amp;e) + (Avg2 * &amp;amp;f); /* Code fails Here */ 
	put Res;
RUN;

%MEND;  

%Test(0.050,0.025,0.03,0.40,0.93,0.25);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 May 2018 17:21:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466138#M118920</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-05-30T17:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: Mean Calculation in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466139#M118921</link>
      <description>&lt;P&gt;&amp;amp;Res line should be&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%Put &amp;amp;Res;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 May 2018 17:24:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466139#M118921</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-05-30T17:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Mean Calculation in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466140#M118922</link>
      <description>&lt;P&gt;Using macros is a very poor choice to do arithmetic. Macros don't like arithmetic operators like your *.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The whole thing would be better programmed in a data step.&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:24:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466140#M118922</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-30T17:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Mean Calculation in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466143#M118923</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; Can data steps be called repeatedly if needed ? For this macro, I tried to write I anticipate calling it repeatedly. So, I was not sure a data step can be called repeatedly in my code. If yes, can you show me an example of how to do what you are recommending and add demonstration around how the data step call can be repeated?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:32:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466143#M118923</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-05-30T17:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Mean Calculation in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466148#M118926</link>
      <description>&lt;P&gt;First you need to explain what you are doing, and why you are doing it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If nothing else, you could use CALL SYMPUTX in the data step to assign values to macro variables, and then you don't run into the problem you had with using an asterisk.&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:49:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466148#M118926</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-30T17:49:24Z</dc:date>
    </item>
    <item>
      <title>Re: Mean Calculation in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466150#M118927</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;&amp;nbsp;I posted the exact code I am building. If you expect me to go into details about the problem I am trying to solve, I am afraid that's not something&amp;nbsp; I can do. You have the exact reference of a simple macro to answer the question with reference to your comments of why you are recommending the use of a data step. I believe that is sufficient to address the question at hand.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:52:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466150#M118927</guid>
      <dc:creator>UdayGuntupalli</dc:creator>
      <dc:date>2018-05-30T17:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: Mean Calculation in Data Step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466151#M118928</link>
      <description>&lt;P&gt;The code posted by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;uses data step commands to do the arithmetic. It's simpler and doesn't have the problem you ran into.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But since you're apparently not going to explain further, there may be extremely simple ways to do this that you will never learn because you aren't going to explain.&lt;/P&gt;</description>
      <pubDate>Wed, 30 May 2018 17:54:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Mean-Calculation-in-Data-Step/m-p/466151#M118928</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2018-05-30T17:54:47Z</dc:date>
    </item>
  </channel>
</rss>

