<?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: Conditionally create unique index in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-create-unique-index/m-p/261244#M50794</link>
    <description>Thanks so much for the help. I appreciate it.</description>
    <pubDate>Mon, 04 Apr 2016 21:53:13 GMT</pubDate>
    <dc:creator>buechler66</dc:creator>
    <dc:date>2016-04-04T21:53:13Z</dc:date>
    <item>
      <title>Conditionally create unique index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-create-unique-index/m-p/261237#M50790</link>
      <description>&lt;P&gt;I have a macro named C&lt;SPAN&gt;reateUniqueIndex. &amp;nbsp;At a certain point in my program I invoke it using the&amp;nbsp;call execute('%CreateUniqueIndex'). &amp;nbsp;But I need to conditionally invoke it only when the index doesn't already existing. I've tried some examples our there, but the conditions seem to be ignored. &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can anyone help me on this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* Build Unique Index ;&lt;BR /&gt;%macro CreateUniqueIndex;&lt;BR /&gt;PROC DATASETS;&lt;BR /&gt;MODIFY FinalData;&lt;BR /&gt;INDEX CREATE imb_code / UNIQUE NOMISS;&lt;BR /&gt;run;&lt;BR /&gt;%mend CreateUniqueIndex;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;* Build unique index if not exist ;&lt;BR /&gt;DATA _NULL_;&lt;BR /&gt;call execute('%CreateUniqueIndex');&lt;BR /&gt;RUN;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 21:17:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-create-unique-index/m-p/261237#M50790</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-04-04T21:17:02Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally create unique index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-create-unique-index/m-p/261240#M50792</link>
      <description>&lt;P&gt;Beside wondering about the need for a macro that has nothing but hardcoded values...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this look like of like what you need?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
   set sashelp.vmember (where=(Libname='WORK' and memname='FINALDATA'));
   if upcase(index) = 'NO' then call execute('%CreateUniqueIndex');
RUN;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Assuming since your macro uses a single level dataset name and no explicit library that the data resides in the Work library.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This checks for the existance of any index. If the data set has an index defined using another variable then it will not create your new index.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2016 21:41:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-create-unique-index/m-p/261240#M50792</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2016-04-04T21:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally create unique index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-create-unique-index/m-p/261244#M50794</link>
      <description>Thanks so much for the help. I appreciate it.</description>
      <pubDate>Mon, 04 Apr 2016 21:53:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-create-unique-index/m-p/261244#M50794</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-04-04T21:53:13Z</dc:date>
    </item>
  </channel>
</rss>

