<?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: Set statement in a macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Set-statement-in-a-macro/m-p/717502#M27513</link>
    <description>&lt;P&gt;It might be a good idea to post some example data and what you expect the result to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One suspects that a macro is not needed and likely an array solution might work&lt;/P&gt;</description>
    <pubDate>Mon, 08 Feb 2021 06:57:25 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2021-02-08T06:57:25Z</dc:date>
    <item>
      <title>Set statement in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-statement-in-a-macro/m-p/717495#M27509</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I think I have a problem with "set" statement when it is in a macro. I have a macro as below and it calculates for only the last statement (speaking). I don't know what I am missing.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;%macro gain(g);&lt;BR /&gt;data a501_403_v1;&lt;BR /&gt;set a501_403;&lt;BR /&gt;&amp;amp;g._ss_gain=&amp;amp;g._ss_501-&amp;amp;g._ss_403;&lt;BR /&gt;&amp;amp;g._pl_gain=&amp;amp;g._pl_501-&amp;amp;g._pl_403;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;%mend;&lt;BR /&gt;%gain (listening);&lt;BR /&gt;%gain (reading);&lt;BR /&gt;%gain (writing);&lt;BR /&gt;%gain (speaking);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 06:29:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-statement-in-a-macro/m-p/717495#M27509</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2021-02-08T06:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: Set statement in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-statement-in-a-macro/m-p/717499#M27511</link>
      <description>&lt;P&gt;Your logic is messed up.&amp;nbsp; You are re-creating the same output dataset each time you call the macro, that is why only the last one still exists.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your problem doesn't really look like something that needs a macro , but if you did want to use a macro you need to have it only generate the two assignment statements.&amp;nbsp; Then you can call it four times in the middle of a single data step.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro gain(g);
&amp;amp;g._ss_gain=&amp;amp;g._ss_501-&amp;amp;g._ss_403;
&amp;amp;g._pl_gain=&amp;amp;g._pl_501-&amp;amp;g._pl_403;
%mend;

data a501_403_v1;
  set a501_403; 
%gain (listening);
%gain (reading);
%gain (writing);
%gain (speaking);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 08 Feb 2021 06:44:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-statement-in-a-macro/m-p/717499#M27511</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-02-08T06:44:11Z</dc:date>
    </item>
    <item>
      <title>Re: Set statement in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-statement-in-a-macro/m-p/717502#M27513</link>
      <description>&lt;P&gt;It might be a good idea to post some example data and what you expect the result to be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One suspects that a macro is not needed and likely an array solution might work&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 06:57:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-statement-in-a-macro/m-p/717502#M27513</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-02-08T06:57:25Z</dc:date>
    </item>
    <item>
      <title>Re: Set statement in a macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Set-statement-in-a-macro/m-p/718014#M27561</link>
      <description>Great! Thank you so much!</description>
      <pubDate>Tue, 09 Feb 2021 20:47:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Set-statement-in-a-macro/m-p/718014#M27561</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2021-02-09T20:47:40Z</dc:date>
    </item>
  </channel>
</rss>

