<?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: Running a program over multiple datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Running-a-program-over-multiple-datasets/m-p/565133#M158612</link>
    <description>&lt;P&gt;You don't need macro code to do what you want. It would be a whole lot easier to extract one dataset containing all accounts transactions sorted by account ID or as I've done here combine your separate datasets in the one step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set OUT_:; * This will read all your separate datasets in; 
by account_id;
retain Balance;
if first.account_id then Balance=Credit-Debit;
else Balance=Balance+Credit-Debit;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jun 2019 07:50:12 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2019-06-11T07:50:12Z</dc:date>
    <item>
      <title>Running a program over multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-program-over-multiple-datasets/m-p/565126#M158607</link>
      <description>&lt;P&gt;Hi, I am looking to run a simple program over a large number of datasets that have been created from a banking system extract.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Essentially we want to extract the transactions for different accounts and then calculate balances for each account. I know how to extract the data by account, and have created some dummy data to add the balance once I've extracted the data by account as below (dummy data attached):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want;&lt;BR /&gt;set OUT_12345;&lt;BR /&gt;retain Balance;&lt;BR /&gt;if _N_=1 then Balance=Credit-Debit;&lt;BR /&gt;else Balance=Balance+Credit-Debit;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I don't know how to do is run the above code over all the datasets (which would be called OUT_12345, OUT_12346, OUT_12347 etc.), I've looked at other solutions but my lack of experience with macros means I'm totally stuck at the moment. Can anyone help?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 07:19:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-program-over-multiple-datasets/m-p/565126#M158607</guid>
      <dc:creator>ICL1986</dc:creator>
      <dc:date>2019-06-11T07:19:02Z</dc:date>
    </item>
    <item>
      <title>Re: Running a program over multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-program-over-multiple-datasets/m-p/565133#M158612</link>
      <description>&lt;P&gt;You don't need macro code to do what you want. It would be a whole lot easier to extract one dataset containing all accounts transactions sorted by account ID or as I've done here combine your separate datasets in the one step&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set OUT_:; * This will read all your separate datasets in; 
by account_id;
retain Balance;
if first.account_id then Balance=Credit-Debit;
else Balance=Balance+Credit-Debit;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 07:50:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-program-over-multiple-datasets/m-p/565133#M158612</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2019-06-11T07:50:12Z</dc:date>
    </item>
    <item>
      <title>Re: Running a program over multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-program-over-multiple-datasets/m-p/565145#M158622</link>
      <description>&lt;P&gt;That's perfect thank you&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2019 08:23:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-program-over-multiple-datasets/m-p/565145#M158622</guid>
      <dc:creator>ICL1986</dc:creator>
      <dc:date>2019-06-11T08:23:01Z</dc:date>
    </item>
    <item>
      <title>Re: Running a program over multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Running-a-program-over-multiple-datasets/m-p/717258#M221790</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;Sorry, late question(s).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To get the proper results, would you not need to sort before combing all the data-sets?&amp;nbsp; &amp;nbsp;Otherwise, is the BY statement really going to get the result you want?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And also, how can just combine like that with set when it wasn't imported?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Sat, 06 Feb 2021 02:23:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Running-a-program-over-multiple-datasets/m-p/717258#M221790</guid>
      <dc:creator>edasdfasdfasdfa</dc:creator>
      <dc:date>2021-02-06T02:23:24Z</dc:date>
    </item>
  </channel>
</rss>

