<?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 Help in my macro pgm in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-macro-pgm/m-p/478393#M123378</link>
    <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am running the below program to find out duplicates in all data sets in sdtm folder. There are (approximately 100) several data sets&amp;nbsp; i think my code works fine but i just want to know if the can be written better way. Please suggest. Thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sdtm "";
proc contents data= sdtm._all_ noprint out= sdtmall ; run;
data sdtmall1(keep=memname name );
set sdtmall;
run;

%macro duplicates;;
data _null_;
    do i=1 to 100;
         set sdtmall1;
         call symputx(cats('in',i),memname);
         call symputx(cats('seq',i),name);
		
     end;
run;
%do i=1 %to 100;
proc sort data=sdtm.&amp;amp;&amp;amp;in&amp;amp;i. out=_null_ dupout=dups__&amp;amp;&amp;amp;in&amp;amp;i. nodupkey;
       by usubjid &amp;amp;&amp;amp;seq&amp;amp;i.;
  run;
  ODS PDF FILE="..pdf";  

  proc print data=dups__&amp;amp;&amp;amp;in&amp;amp;i. width=min ;
  	   title " Dups in sdtm.&amp;amp;&amp;amp;in&amp;amp;i.";
  	   var usubjid &amp;amp;&amp;amp;seq&amp;amp;i.;
  run;	 
  ods pdf close;
  %end;
%mend;
%duplicates;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 16 Jul 2018 15:17:55 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2018-07-16T15:17:55Z</dc:date>
    <item>
      <title>Help in my macro pgm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-macro-pgm/m-p/478393#M123378</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am running the below program to find out duplicates in all data sets in sdtm folder. There are (approximately 100) several data sets&amp;nbsp; i think my code works fine but i just want to know if the can be written better way. Please suggest. Thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname sdtm "";
proc contents data= sdtm._all_ noprint out= sdtmall ; run;
data sdtmall1(keep=memname name );
set sdtmall;
run;

%macro duplicates;;
data _null_;
    do i=1 to 100;
         set sdtmall1;
         call symputx(cats('in',i),memname);
         call symputx(cats('seq',i),name);
		
     end;
run;
%do i=1 %to 100;
proc sort data=sdtm.&amp;amp;&amp;amp;in&amp;amp;i. out=_null_ dupout=dups__&amp;amp;&amp;amp;in&amp;amp;i. nodupkey;
       by usubjid &amp;amp;&amp;amp;seq&amp;amp;i.;
  run;
  ODS PDF FILE="..pdf";  

  proc print data=dups__&amp;amp;&amp;amp;in&amp;amp;i. width=min ;
  	   title " Dups in sdtm.&amp;amp;&amp;amp;in&amp;amp;i.";
  	   var usubjid &amp;amp;&amp;amp;seq&amp;amp;i.;
  run;	 
  ods pdf close;
  %end;
%mend;
%duplicates;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 16 Jul 2018 15:17:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-my-macro-pgm/m-p/478393#M123378</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-07-16T15:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Help in my macro pgm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-macro-pgm/m-p/478400#M123380</link>
      <description>&lt;P&gt;Things I'd change:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Store the results into a data set and reporting it after all the comparisons are complete. If you need to change things it's easier and it gives you more flexibility.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Change the hard code of 100 to be dynamic based on the number of your data sets&lt;/LI&gt;
&lt;LI&gt;Clean up - drop datasets after you're done with them, no need to keep them lying around for mistakes. This means you can also reduce the &amp;amp;&amp;amp; usage and use temp data sets instead with the same name. In&amp;nbsp;the long run this approach is easier to debug and maintain.&amp;nbsp;&lt;/LI&gt;
&lt;LI&gt;Consider switching a macro loop to a full macro and use CALL EXECUTE to run it. Then you don't have to worry about any of the above as well....&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;But if it works, it works so you don't actually have to change anything.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Jul 2018 15:42:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-my-macro-pgm/m-p/478400#M123380</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-07-16T15:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Help in my macro pgm</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-in-my-macro-pgm/m-p/478575#M123420</link>
      <description>&lt;P&gt;One possibility is to write your code a temporary file and then execute that:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data= sdtm._all_ noprint out= sdtmall ; run;

filename tempsas temp;
data _null_;
  set sdtmall;
  where upcase(name) ne 'USUBJID';
  file tempsas;
  put 
    'Proc sort data=sdtm.' memname 'out=_null_ dupout=dups__' memname 'nodupkey;' /
    '  by usubjid ' name ';' /
    'run;' /
    'ODS PDF FILE="..pdf";' /
    'Title "Dups in sdtm.' memname '";' /
    'Proc print data=dups__' memname Width=min; /
    '  var usubjid ' name ';'/
    'run;'/
   'ODS PDF close;' /
   ;
run;
%include tempsas /source2;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Before actually submitting the %INCLUDE statement, you may want to have a look at the TEMPSAS file, and perhaps submit the first block of code to see if everything goes well. A lot easier to debug than macros.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit note: after submitting the post, I realised that the code (and your original code as well) will generate a lot of statements like&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort;
  by usubjid usubjid;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;which is probably not what you want, so I added the WHERE clause to avoid that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 08:13:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-in-my-macro-pgm/m-p/478575#M123420</guid>
      <dc:creator>s_lassen</dc:creator>
      <dc:date>2018-07-17T08:13:44Z</dc:date>
    </item>
  </channel>
</rss>

