<?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: Performing the same Datastep on many similar data files in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505534#M135384</link>
    <description>&lt;P&gt;True, but then you would assume that if the process is that similar for each of these datasets either - its data split out before, data that can be set together retaining on necessary variables, or data from which the process of counting id could be extracted from the data and then re-merged.&amp;nbsp; Those scenarios are pretty simple, if its more complicated that that, maybe assess the steps before.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Oct 2018 13:35:13 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2018-10-18T13:35:13Z</dc:date>
    <item>
      <title>Performing the same Datastep on many similar data files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505519#M135377</link>
      <description>&lt;P&gt;I have a number of data files that I want to count observations per group for, in addition to removing id's with only one observation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To do this with a single data file I can use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA want;
    SET have;
    BY id date;
    IF first.id THEN count=0; 
    count+1;
   IF first.id AND last.id THEN DELETE;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Is there anyway I can set this up as a macro to run it on 5+ data files?&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 13:05:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505519#M135377</guid>
      <dc:creator>MB_Analyst</dc:creator>
      <dc:date>2018-10-18T13:05:34Z</dc:date>
    </item>
    <item>
      <title>Re: Performing the same Datastep on many similar data files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505521#M135379</link>
      <description>&lt;P&gt;Untested:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro MACRO_NAME(Have=, Want=);
data &amp;amp;want.;
   set &amp;amp;have.;
   by id date;

   if first.id then
      count=0;
   count+1;

   if first.id and last.id then
      delete;
run;
%mend;

%MACRO_NAME(Have= have, Want= want)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 13:12:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505521#M135379</guid>
      <dc:creator>andreas_lds</dc:creator>
      <dc:date>2018-10-18T13:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Performing the same Datastep on many similar data files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505525#M135381</link>
      <description>&lt;P&gt;You don't need macro, you can simply combine the datasets you want to check, then process them using by groups.&amp;nbsp; It will be faster and use less resources.&amp;nbsp; Post some test data for an exact example but:&lt;/P&gt;
&lt;PRE&gt;data want;
  set dataset1 dataset2 dataset3... indsname=tmp;
  dsname=tmp;
run;
data want;
  set want;
  by dsname id;
  if first.id then count=0;
  count=sum(count,1);
  if first.id and last.id then delete;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 13:17:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505525#M135381</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-18T13:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: Performing the same Datastep on many similar data files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505526#M135382</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/45151"&gt;@RW9&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You don't need macro, you can simply combine the datasets you want to check, then process them using by groups.&amp;nbsp; It will be faster and use less resources.&amp;nbsp; Post some test data for an exact example but:&lt;/P&gt;
&lt;PRE&gt;data want;
  set dataset1 dataset2 dataset3... indsname=tmp;
  dsname=tmp;
run;
data want;
  set want;
  by dsname id;
  if first.id then count=0;
  count=sum(count,1);
  if first.id and last.id then delete;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;That gets messy if the only common variable(s) are the ID variables.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 13:20:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505526#M135382</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2018-10-18T13:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Performing the same Datastep on many similar data files</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505534#M135384</link>
      <description>&lt;P&gt;True, but then you would assume that if the process is that similar for each of these datasets either - its data split out before, data that can be set together retaining on necessary variables, or data from which the process of counting id could be extracted from the data and then re-merged.&amp;nbsp; Those scenarios are pretty simple, if its more complicated that that, maybe assess the steps before.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 13:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Performing-the-same-Datastep-on-many-similar-data-files/m-p/505534#M135384</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-10-18T13:35:13Z</dc:date>
    </item>
  </channel>
</rss>

