<?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 Conditionally creating an Index in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-creating-an-Index/m-p/279386#M56308</link>
    <description>&lt;P&gt;Hi. I'm trying to conditionally create an index, but only if it doesn't already exist. Can anyone help me with this? This attempt isn't working for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;		data _null_;
			set sashelp.vmember (where=(Libname='WORK' and memname='FINALDATA%unquote(&amp;amp;zip5)'));
			if upcase(index) = 'NO' then do;
				PROC DATASETS;
				MODIFY FinalData%unquote(&amp;amp;zip5);
				INDEX CREATE imb_code /unique;
			end;
		RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 22 Jun 2016 15:21:02 GMT</pubDate>
    <dc:creator>buechler66</dc:creator>
    <dc:date>2016-06-22T15:21:02Z</dc:date>
    <item>
      <title>Conditionally creating an Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-creating-an-Index/m-p/279386#M56308</link>
      <description>&lt;P&gt;Hi. I'm trying to conditionally create an index, but only if it doesn't already exist. Can anyone help me with this? This attempt isn't working for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;		data _null_;
			set sashelp.vmember (where=(Libname='WORK' and memname='FINALDATA%unquote(&amp;amp;zip5)'));
			if upcase(index) = 'NO' then do;
				PROC DATASETS;
				MODIFY FinalData%unquote(&amp;amp;zip5);
				INDEX CREATE imb_code /unique;
			end;
		RUN;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 22 Jun 2016 15:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-creating-an-Index/m-p/279386#M56308</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-22T15:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally creating an Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-creating-an-Index/m-p/279390#M56310</link>
      <description>&lt;P&gt;Well, this will give you a start, but I don't know what that macro variable is or why it is there at all:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vmember (where=(Libname='WORK' and memname='FINALDATA%unquote(&amp;amp;zip5)'));&lt;BR /&gt;  if upcase(index)='NO' then call execute('proc datasets; modify finaldata'||&amp;amp;zip5.||'; index create imb_code /unique; run; quit;');
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2016 15:27:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-creating-an-Index/m-p/279390#M56310</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-06-22T15:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally creating an Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-creating-an-Index/m-p/279395#M56314</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; wrote:&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vmember (where=(Libname='WORK' and memname='FINALDATA%unquote(&amp;amp;zip5)'));&lt;BR /&gt;  if upcase(index)='NO' then call execute('proc datasets; modify finaldata'||&amp;amp;zip5.||'; index create imb_code /unique; run; quit;');
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My 2 cents on this:&amp;nbsp;this code will not create an index if &lt;EM&gt;any&lt;/EM&gt; index exists. It is not specific to index imb_code. So there may still be room for improvement. But kudo's to the use of call execute(). Very underestimated and often misunderstood.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;- Jan.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2016 15:35:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-creating-an-Index/m-p/279395#M56314</guid>
      <dc:creator>jklaverstijn</dc:creator>
      <dc:date>2016-06-22T15:35:32Z</dc:date>
    </item>
    <item>
      <title>Re: Conditionally creating an Index</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Conditionally-creating-an-Index/m-p/279539#M56343</link>
      <description>Thank you. I appreciate your time.</description>
      <pubDate>Wed, 22 Jun 2016 19:38:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Conditionally-creating-an-Index/m-p/279539#M56343</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-06-22T19:38:10Z</dc:date>
    </item>
  </channel>
</rss>

