<?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 Need to run code on 100 different datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-run-code-on-100-different-datasets/m-p/795810#M255294</link>
    <description>&lt;P&gt;I'd like to run the same exact code on 100 different datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far I've been dragging manually each dataset to one particular 'library' for code execution.&amp;nbsp; I've named each dataset the same, 'xyz.sas7bdat,' to make the job easier -- no need to tailor the code for each different dataset.&amp;nbsp; After each run I move the results to a folder specifically for that particular dataset.&amp;nbsp; And then proceed on to the next dataset.&amp;nbsp; x100.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's got to be a better way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm thinking of creating a 'library' for each and every dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname _001 'c:\datasets\_001';&lt;/P&gt;
&lt;P&gt;libname _002 'c:\datasets\_002';&lt;/P&gt;
&lt;P&gt;libname _003 'c:\datasets\_003';&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That way the datasets can stay put in their respective folder.&amp;nbsp; No need to manually drag anywhere.&amp;nbsp; Hopefully all code execution results will stay in the respective folder as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can set up the code so that execution goes through all the datasets, one at a time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No need to run the code separately 100 times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, you get the drift.&amp;nbsp; Guidance greatly appreciated....&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;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 12 Feb 2022 02:02:34 GMT</pubDate>
    <dc:creator>NKormanik</dc:creator>
    <dc:date>2022-02-12T02:02:34Z</dc:date>
    <item>
      <title>Need to run code on 100 different datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-run-code-on-100-different-datasets/m-p/795810#M255294</link>
      <description>&lt;P&gt;I'd like to run the same exact code on 100 different datasets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far I've been dragging manually each dataset to one particular 'library' for code execution.&amp;nbsp; I've named each dataset the same, 'xyz.sas7bdat,' to make the job easier -- no need to tailor the code for each different dataset.&amp;nbsp; After each run I move the results to a folder specifically for that particular dataset.&amp;nbsp; And then proceed on to the next dataset.&amp;nbsp; x100.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There's got to be a better way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm thinking of creating a 'library' for each and every dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname _001 'c:\datasets\_001';&lt;/P&gt;
&lt;P&gt;libname _002 'c:\datasets\_002';&lt;/P&gt;
&lt;P&gt;libname _003 'c:\datasets\_003';&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That way the datasets can stay put in their respective folder.&amp;nbsp; No need to manually drag anywhere.&amp;nbsp; Hopefully all code execution results will stay in the respective folder as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can set up the code so that execution goes through all the datasets, one at a time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;No need to run the code separately 100 times.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well, you get the drift.&amp;nbsp; Guidance greatly appreciated....&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;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Feb 2022 02:02:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-run-code-on-100-different-datasets/m-p/795810#M255294</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2022-02-12T02:02:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need to run code on 100 different datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-run-code-on-100-different-datasets/m-p/795812#M255296</link>
      <description>&lt;P&gt;Indeed there is a better way and it is really simple. Create a controlling program to run before your main static code program.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now set up your data in a single library but name each of your 100 datasets with a number suffix like xyz001, xyz002 etc. Then in the controlling program do this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
  do I = 1 to 100;
    call execute('data xyz; set xyz' !! put(i,z3.) !! ';run; %include MyCode.sas; run;');
  end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This code will loop 100 times, first copying the required input dataset from xyz001 (and so on) to xyz, then include and run your main program.&lt;/P&gt;</description>
      <pubDate>Sat, 12 Feb 2022 02:34:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-run-code-on-100-different-datasets/m-p/795812#M255296</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2022-02-12T02:34:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need to run code on 100 different datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-run-code-on-100-different-datasets/m-p/795839#M255313</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22691"&gt;@NKormanik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I'm thinking of creating a 'library' for each and every dataset:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;libname _001 'c:\datasets\_001';&lt;/P&gt;
&lt;P&gt;libname _002 'c:\datasets\_002';&lt;/P&gt;
&lt;P&gt;libname _003 'c:\datasets\_003';&lt;/P&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;No need to do this renaming. No need to set up a library with numeric-like names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Create a text file, where the text on each line is the full folder name and file name. Read this text file into a SAS data set, then loop through each record, and do the import for the file name in each record (similar to the solution from &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13976"&gt;@SASKiwi&lt;/a&gt; but without the renaming and renumbering).&lt;/P&gt;</description>
      <pubDate>Sat, 12 Feb 2022 14:15:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-run-code-on-100-different-datasets/m-p/795839#M255313</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-12T14:15:04Z</dc:date>
    </item>
  </channel>
</rss>

