<?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 function with macro in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685229#M24284</link>
    <description>Thank you so much!</description>
    <pubDate>Sat, 19 Sep 2020 21:42:45 GMT</pubDate>
    <dc:creator>dustychair</dc:creator>
    <dc:date>2020-09-19T21:42:45Z</dc:date>
    <item>
      <title>set function with macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685225#M24280</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I have a question on combining some data sets with macro. I have 4 tests and 12 grades. I would like to combine all of the grades for each relevant test. I don't get any error with the below code but it is taking only grade 12. Could you help me with what I am missing?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%macro combine(k);&lt;BR /&gt;data &amp;amp;k._pl_all_n;&lt;BR /&gt;%do i=1 %to 12;&lt;BR /&gt;set pls_&amp;amp;k._gr_&amp;amp;i. ; &lt;BR /&gt;%end;&lt;BR /&gt;run;&lt;BR /&gt;%mend;&lt;BR /&gt;%combine(listening);&lt;BR /&gt;%combine(writing);&lt;BR /&gt;%combine(speaking);&lt;BR /&gt;%combine(reading);&lt;/P&gt;</description>
      <pubDate>Sat, 19 Sep 2020 21:26:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685225#M24280</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2020-09-19T21:26:58Z</dc:date>
    </item>
    <item>
      <title>Re: set function with macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685226#M24281</link>
      <description>&lt;P&gt;You need a SET statement with a list of datasets, not a list of set statements where each overwrites the preceeding:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro combine(k);
data &amp;amp;k._pl_all_n;
set 
%do i=1 %to 12;
    pls_&amp;amp;k._gr_&amp;amp;i.
    %end;
; 
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Sep 2020 21:34:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685226#M24281</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-09-19T21:34:51Z</dc:date>
    </item>
    <item>
      <title>Re: set function with macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685227#M24282</link>
      <description>&lt;P&gt;Note that you could just as well use a dataset list:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro combine(k);
data &amp;amp;k._pl_all_n;
set pls_&amp;amp;k._gr_1 - pls_&amp;amp;k._gr_12;
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Sep 2020 21:40:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685227#M24282</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2020-09-19T21:40:10Z</dc:date>
    </item>
    <item>
      <title>Re: set function with macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685228#M24283</link>
      <description>&lt;P&gt;Your macro creates these statements (SET is a&amp;nbsp;&lt;EM&gt;statement&lt;/EM&gt;, not a&amp;nbsp;&lt;EM&gt;function&lt;/EM&gt;!):&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;set pls_listening_gr_1;
set pls_listening_gr_2;
set pls_listening_gr_3;
set pls_listening_gr_4;
set pls_listening_gr_4;
set pls_listening_gr_5;
set pls_listening_gr_6;
set pls_listening_gr_7;
set pls_listening_gr_8;
set pls_listening_gr_9;
set pls_listening_gr_10;
set pls_listening_gr_11;
set pls_listening_gr_12;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;so the data step reads an observation each from all 12 datasets (overwriting the PDV each time), and only the data from the last read remains to be written to the output dataset.&lt;/P&gt;
&lt;P&gt;Move the SET statement out of the macro loop:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro combine(k);
data &amp;amp;k._pl_all_n;
set
%do i=1 %to 12;
  pls_&amp;amp;k._gr_&amp;amp;i.
%end;
;
run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 19 Sep 2020 21:40:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685228#M24283</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-19T21:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: set function with macro</title>
      <link>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685229#M24284</link>
      <description>Thank you so much!</description>
      <pubDate>Sat, 19 Sep 2020 21:42:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/set-function-with-macro/m-p/685229#M24284</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2020-09-19T21:42:45Z</dc:date>
    </item>
  </channel>
</rss>

