<?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: Use macro &amp;quot;Calculation&amp;quot; in datastep? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710917#M218927</link>
    <description>You generally put things in a macro if they'll be re-used or need to be generalized somehow. I fail to see how this is generalized, so I'm assuming this is being done because you plan to repeat it a few times in different places?&lt;BR /&gt;</description>
    <pubDate>Tue, 12 Jan 2021 20:20:38 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-01-12T20:20:38Z</dc:date>
    <item>
      <title>Use macro "Calculation" in datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710905#M218918</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I have a 'Calculation' Macro over 200 lines.&lt;/P&gt;
&lt;PRE&gt;%macro calculated;&lt;BR /&gt;if c_ageyears=. and agemonths=. and ageyears ne . then do;&lt;BR /&gt;&amp;nbsp;c_ageyears=floor(ageyears);&lt;BR /&gt;&amp;nbsp;c_ageyears_fix=1;&lt;BR /&gt;end;&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;%mend calculated;&lt;/PRE&gt;
&lt;P&gt;And I would like to use this calculating macro to the data step.&lt;/P&gt;
&lt;PRE&gt;data update_test2016;
set test2106;
if c_ageyears=. and agemonths=. and ageyears ne . then do;
 c_ageyears=floor(ageyears);
 c_ageyears_fix=1;
end;
.
.
.
run;

&lt;/PRE&gt;
&lt;P&gt;So when every time I run&amp;nbsp;a new year,&amp;nbsp;for example from 2017 to 2019,&amp;nbsp;&amp;nbsp;I have to copy 200 lines&amp;nbsp;from the first macro into the data steps to do the calculation.&amp;nbsp;&amp;nbsp; Is there a way so that I could just use one or two command lines to run the macro repeatedly, such as %includes or something else?&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 19:14:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710905#M218918</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2021-01-12T19:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: Use macro "Calculation" in datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710906#M218919</link>
      <description>&lt;P&gt;%include isn't needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This should work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data update_test2016;
set test2106;
%calculated
.
.
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jan 2021 19:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710906#M218919</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-12T19:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: Use macro "Calculation" in datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710907#M218920</link>
      <description>&lt;P&gt;But how to&amp;nbsp;direct the SAS run&amp;nbsp;this macro file with specific file location?&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN style="color: #2f5496;"&gt;&lt;A target="_blank"&gt;\\pathway\Programs\macro_calculation.sas&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 19:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710907#M218920</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2021-01-12T19:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: Use macro "Calculation" in datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710910#M218922</link>
      <description>&lt;P&gt;It seems that the macro is written to make the calculation for any file that has all variables mentioned in it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The part of the macro that you posted does not relate to a specific file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To be able to use the macro in a data step you can either:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%include "\\pathway\Programs\macro_calculation.sas";

data update_test2016;
   set test2106;
...
   %calculated;
...
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;OR&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename macros "\\pathway\Programs";
options sasautos=(macros, sasautos);

data update_test2016;
set test2106;
...
%calculated;
...
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 12 Jan 2021 19:54:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710910#M218922</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-01-12T19:54:08Z</dc:date>
    </item>
    <item>
      <title>Re: Use macro "Calculation" in datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710911#M218923</link>
      <description>&lt;P&gt;Given that this macro has variables specific to this task, I would just put it in your program above the data step.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 19:55:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710911#M218923</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-01-12T19:55:27Z</dc:date>
    </item>
    <item>
      <title>Re: Use macro "Calculation" in datastep?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710917#M218927</link>
      <description>You generally put things in a macro if they'll be re-used or need to be generalized somehow. I fail to see how this is generalized, so I'm assuming this is being done because you plan to repeat it a few times in different places?&lt;BR /&gt;</description>
      <pubDate>Tue, 12 Jan 2021 20:20:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Use-macro-quot-Calculation-quot-in-datastep/m-p/710917#M218927</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-01-12T20:20:38Z</dc:date>
    </item>
  </channel>
</rss>

