<?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: Any function to dedup sas macros ? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/684978#M207681</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/342595"&gt;@fierceanalytics&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13683"&gt;@ArtC&lt;/a&gt;'s book "Carpenter's Complete Guide to the SAS Macro Language, Third Edition" that he includes a macro to remove duplicate values (Program 12.4.7, "DistinctList").&amp;nbsp; I suspect that if Mr. Carpenter isn't aware of an official SAS macro to remove duplicates that there isn't one.&amp;nbsp; However, if you do find one, please post the name here; it would be a useful macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
    <pubDate>Fri, 18 Sep 2020 14:13:38 GMT</pubDate>
    <dc:creator>jimbarbour</dc:creator>
    <dc:date>2020-09-18T14:13:38Z</dc:date>
    <item>
      <title>Any function to dedup sas macros ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/684966#M207677</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not looking for all kinds of ways how to dedup macro values when combining them into one. I have code that does that. Wonder if there is a built SAS sys functon of some sort that does that in one. For example&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%let new100 = %sysdedup(&amp;amp;old1 &amp;amp;old2 .... &amp;amp;old100 &amp;amp;old102);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%sysdedup is just my creation that needs to be replaced with a legit one if any.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jia Xin&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 13:23:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/684966#M207677</guid>
      <dc:creator>fierceanalytics</dc:creator>
      <dc:date>2020-09-18T13:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Any function to dedup sas macros ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/684978#M207681</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/342595"&gt;@fierceanalytics&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I see in&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13683"&gt;@ArtC&lt;/a&gt;'s book "Carpenter's Complete Guide to the SAS Macro Language, Third Edition" that he includes a macro to remove duplicate values (Program 12.4.7, "DistinctList").&amp;nbsp; I suspect that if Mr. Carpenter isn't aware of an official SAS macro to remove duplicates that there isn't one.&amp;nbsp; However, if you do find one, please post the name here; it would be a useful macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 14:13:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/684978#M207681</guid>
      <dc:creator>jimbarbour</dc:creator>
      <dc:date>2020-09-18T14:13:38Z</dc:date>
    </item>
    <item>
      <title>Re: Any function to dedup sas macros ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/684996#M207692</link>
      <description>&lt;P&gt;Jim&lt;/P&gt;&lt;P&gt;Found the mentioned code 12.4.7. Sign on SAS support site. Look for the Macro book. Download 67815_example.zip.&amp;nbsp; The program is 12.4.7, but as of 9-18-2020, the online example copy puts it under Chapter 12 12.4.6.sas. The macro is&amp;nbsp;%macro DistinctList(list).... Not to sound critical, it is kind of long.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jia Xin&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 14:58:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/684996#M207692</guid>
      <dc:creator>fierceanalytics</dc:creator>
      <dc:date>2020-09-18T14:58:47Z</dc:date>
    </item>
    <item>
      <title>Re: Any function to dedup sas macros ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/685006#M207696</link>
      <description>&lt;P&gt;It is not clear what you mean, but I don't think there is anything like that.&lt;/P&gt;
&lt;P&gt;Sounds like you want way to generate a macro variable that has the distinct set of words that are in the existing value.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dedup(words);
%local return i word ;
%do i=1 %to %sysfunc(countw(&amp;amp;words,%str( )));
  %let word=%scan(&amp;amp;words,&amp;amp;i,%str( ));
  %if not %sysfunc(indexw(&amp;amp;return,&amp;amp;word,%str( ))) %then
    %let return=&amp;amp;return &amp;amp;word
  ;
%end;
&amp;amp;return
%mend dedup;
%put %dedup(a b c a a b d);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If instead you want to give it a list of the names of macro variables and find the set of distinct values of those macro variables you could re-write it this way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro dedupvars(vars);
%local return i var ;
%do i=1 %to %sysfunc(countw(&amp;amp;vars,%str( )));
  %let var=%scan(&amp;amp;vars,&amp;amp;i,%str( ));
  %if not %sysfunc(indexw(&amp;amp;return,&amp;amp;&amp;amp;&amp;amp;var,%str( ))) %then
    %let return=&amp;amp;return &amp;amp;&amp;amp;&amp;amp;var
  ;
%end;
&amp;amp;return
%mend dedupvars;

%let a=a;
%let b=b;
%let c=a;
%put %dedupvars(a b c);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Sep 2020 15:27:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/685006#M207696</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2020-09-18T15:27:37Z</dc:date>
    </item>
    <item>
      <title>Re: Any function to dedup sas macros ?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/685022#M207700</link>
      <description>&lt;P&gt;I have 6 macros that do this. I was just looking for a built in SAS function to simplify. Thank you. Jia&lt;/P&gt;</description>
      <pubDate>Fri, 18 Sep 2020 16:10:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Any-function-to-dedup-sas-macros/m-p/685022#M207700</guid>
      <dc:creator>fierceanalytics</dc:creator>
      <dc:date>2020-09-18T16:10:48Z</dc:date>
    </item>
  </channel>
</rss>

