<?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: How to run the same code for different data sets? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431125#M68656</link>
    <description>&lt;P&gt;You should learn to&lt;STRONG&gt; call- call execute &lt;/STRONG&gt;after having your dataset names list in a variable&lt;STRONG&gt;.&lt;/STRONG&gt; To learn how to &lt;STRONG&gt;call call execute,&lt;/STRONG&gt; google it. I don't know how many would have the time or will to explain in detail Anyway good luck&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jan 2018 23:12:37 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2018-01-25T23:12:37Z</dc:date>
    <item>
      <title>How to run the same code for different data sets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431121#M68655</link>
      <description>&lt;P&gt;I have around 50 data sets with same variables. I have to add, drop and rename some variables in each of these data sets. Can I run a macro to run the code simultaneously on all files? Or is there any other way?&lt;/P&gt;&lt;P&gt;PS I am pretty new to SAS; please try to explain in detail.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 22:32:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431121#M68655</guid>
      <dc:creator>abubakrayesh</dc:creator>
      <dc:date>2018-01-25T22:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to run the same code for different data sets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431125#M68656</link>
      <description>&lt;P&gt;You should learn to&lt;STRONG&gt; call- call execute &lt;/STRONG&gt;after having your dataset names list in a variable&lt;STRONG&gt;.&lt;/STRONG&gt; To learn how to &lt;STRONG&gt;call call execute,&lt;/STRONG&gt; google it. I don't know how many would have the time or will to explain in detail Anyway good luck&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 23:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431125#M68656</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2018-01-25T23:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to run the same code for different data sets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431128#M68657</link>
      <description>&lt;P&gt;First rule - get it working for one data set first, with no bugs. Then try and change that for another data set and note all the things you have to change. Then you can work on automating it.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A walk through of macros is here&lt;/P&gt;
&lt;P&gt;&lt;A href="https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/" target="_blank"&gt;https://stats.idre.ucla.edu/sas/seminars/sas-macros-introduction/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need help, I suggest posting your working code, highlighting what you need to be dynamic, which you identified from the first step and we can help with the automation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/188982"&gt;@abubakrayesh&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;I have around 50 data sets with same variables. I have to add, drop and rename some variables in each of these data sets. Can I run a macro to run the code simultaneously on all files? Or is there any other way?&lt;/P&gt;
&lt;P&gt;PS I am pretty new to SAS; please try to explain in detail.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jan 2018 23:21:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431128#M68657</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-01-25T23:21:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to run the same code for different data sets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431206#M68659</link>
      <description>&lt;P&gt;Do you know the names of all the data sets? And if yes, are these names in a data set?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 10:27:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431206#M68659</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-01-26T10:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to run the same code for different data sets?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431219#M68662</link>
      <description>&lt;P&gt;If you have the program for one dataset, I would suggest trying this: Write another SAS program, which writes the first program, and put the variable parameters in datastep variables, e.g.:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename tempsas temp; /* you can also allocate a permanent file here */
data _null_;
  input dsname $;
  file tempsas;
  put 
    'data outlib.' dsname ';'  /
    '  set inlib.' dsname '(keep=a b c d f);' /
    '  where c&amp;lt;33;' /
    'run;' /
    ;
cards;
mydata
yourdata
hisdata
herdata
ourdata
;run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You can then take a look at the code that is generated (open the TEMPSAS file in an editor window). If it looks OK, try submitting one code section (one datastep in the example), and see if the results are what you expected. If it looks OK, submit some more and check the log and the output. If something goes wrong, go back and change the original program (the one that wrote the code) and submit it again.&lt;/P&gt;&lt;P&gt;When all looks OK, you can insert the line "%include tempsas;" at the bottom of your original program.&lt;/P&gt;&lt;P&gt;A lot of people want to use macros and call execute. That may work too, but you have a lot less control of the process, and it is much harder to debug.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2018 11:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-to-run-the-same-code-for-different-data-sets/m-p/431219#M68662</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-01-26T11:42:31Z</dc:date>
    </item>
  </channel>
</rss>

