<?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 use proc contents output to run proc sort with nodupkey in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-proc-contents-output-to-run-proc-sort-with-nodupkey/m-p/478707#M123471</link>
    <description>&lt;P&gt;Hi - I would set up some kind of loop to read through your list of data sets. Instead of proc contents, I used the dictionary.tables data set. Then in your macro you can use a %do loop to go through each data set. I've assumed that each of your sequence variables is named like the table, so you can use &amp;amp;in. to achieve the same thing as &amp;amp;seq. If that's not the case, you'd have to get creative to identify the sequence variable as well.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Create a list of tables in question*/
proc sql noprint;
	select memname
	into :table_list separated by ' '
	from dictionary.tables
	where upcase(libname) eq 'WORK'
	and   upcase(memname) in ('TEST');
quit;
%let table_count = %sysfunc(countw(&amp;amp;table_list.)); /*Count how many need to be looped across*/

/*Begin process of identifying duplicates*/
%macro duplicates;

	%do i=1 %to &amp;amp;table_count.;
		%let in=%scan(&amp;amp;table_list.,&amp;amp;i.,' ');

		proc sort data=sdtm.&amp;amp;in. out=_null_ dupout=dups__&amp;amp;in. nodupkey;
			by usubjid &amp;amp;in.seq;
		run;

		proc print data=dups__&amp;amp;in. width=min ;
		title "Dups in sdtm.&amp;amp;in.";
		var usubjid &amp;amp;in.seq;
		run;	 

	%end;

%mend;
%duplicates;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Jul 2018 16:28:15 GMT</pubDate>
    <dc:creator>lrudolphi</dc:creator>
    <dc:date>2018-07-17T16:28:15Z</dc:date>
    <item>
      <title>How to use proc contents output to run proc sort with nodupkey</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-proc-contents-output-to-run-proc-sort-with-nodupkey/m-p/477646#M123066</link>
      <description>&lt;P&gt;Dear,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a question for simplifying my code.&amp;nbsp; I need to find out duplicate values in my data set. Since there are several data sets in the folder is there way i can use proc contents information to run . Currently i am calling several macro calls like the i called %duplicates(in=ae,seq=aeseq).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of calling several&amp;nbsp; &amp;nbsp;"&lt;SPAN&gt;%duplicates(in=ae,seq=aeseq)' i want to see if i can simplify the code. Please suggest. Thank you&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data= sdtm._all_ noprint out= sdtmall(where=(name in ('AESEQ' 'IDVARVAL'))) ; run;

%macro duplicates(in=,seq=);
proc sort data=sdtm.&amp;amp;in. out=_null_ dupout=dups__&amp;amp;in. nodupkey;
       by usubjid &amp;amp;seq.;
  run;
  proc print data=dups__&amp;amp;in. width=min ;
  	   title " Dups in sdtm.&amp;amp;in.";
  	   var usubjid &amp;amp;seq.;
  run;	 
%mend;
%duplicates(in=ae,seq=aeseq);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jul 2018 18:05:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-proc-contents-output-to-run-proc-sort-with-nodupkey/m-p/477646#M123066</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2018-07-12T18:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to use proc contents output to run proc sort with nodupkey</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-use-proc-contents-output-to-run-proc-sort-with-nodupkey/m-p/478707#M123471</link>
      <description>&lt;P&gt;Hi - I would set up some kind of loop to read through your list of data sets. Instead of proc contents, I used the dictionary.tables data set. Then in your macro you can use a %do loop to go through each data set. I've assumed that each of your sequence variables is named like the table, so you can use &amp;amp;in. to achieve the same thing as &amp;amp;seq. If that's not the case, you'd have to get creative to identify the sequence variable as well.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*Create a list of tables in question*/
proc sql noprint;
	select memname
	into :table_list separated by ' '
	from dictionary.tables
	where upcase(libname) eq 'WORK'
	and   upcase(memname) in ('TEST');
quit;
%let table_count = %sysfunc(countw(&amp;amp;table_list.)); /*Count how many need to be looped across*/

/*Begin process of identifying duplicates*/
%macro duplicates;

	%do i=1 %to &amp;amp;table_count.;
		%let in=%scan(&amp;amp;table_list.,&amp;amp;i.,' ');

		proc sort data=sdtm.&amp;amp;in. out=_null_ dupout=dups__&amp;amp;in. nodupkey;
			by usubjid &amp;amp;in.seq;
		run;

		proc print data=dups__&amp;amp;in. width=min ;
		title "Dups in sdtm.&amp;amp;in.";
		var usubjid &amp;amp;in.seq;
		run;	 

	%end;

%mend;
%duplicates;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jul 2018 16:28:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-use-proc-contents-output-to-run-proc-sort-with-nodupkey/m-p/478707#M123471</guid>
      <dc:creator>lrudolphi</dc:creator>
      <dc:date>2018-07-17T16:28:15Z</dc:date>
    </item>
  </channel>
</rss>

