<?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: More troubles with Indexes in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/More-troubles-with-Indexes/m-p/268516#M53158</link>
    <description>Thanks very much!</description>
    <pubDate>Thu, 05 May 2016 13:47:10 GMT</pubDate>
    <dc:creator>buechler66</dc:creator>
    <dc:date>2016-05-05T13:47:10Z</dc:date>
    <item>
      <title>More troubles with Indexes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-troubles-with-Indexes/m-p/268498#M53152</link>
      <description>&lt;P&gt;Hi. I'm trying to create a unique index for both spm_calc_batch_date and imb_code together (composite). The error message I'm getting has me thinking I've created two individual unique indexes instead of one. I'm trying to reject records with the same &lt;SPAN&gt;spm_calc_batch_date and imb_code. &amp;nbsp;&lt;/SPAN&gt;Am I doing something wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Macro to create Unique Index ;
%macro CreateUniqueIndex;
	PROC DATASETS;
	MODIFY FinalData;
	INDEX CREATE spm_calc_batch_date imb_code / UNIQUE NOMISS;
	run;
%mend CreateUniqueIndex;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;MLOGIC(CREATEUNIQUEINDEX):  Beginning execution.
MLOGIC(CREATEUNIQUEINDEX):  Ending execution.
NOTE: There were 1 observations read from the data set SASHELP.VMEMBER.
      WHERE (Libname='WORK') and (memname='FINALDATA');

NOTE: CALL EXECUTE generated line.
1   + PROC DATASETS;
                                                          Directory

                                  Libref             WORK
                                  Engine             V9
                                  Physical Name      /saswork/SAS_work014A01900110_imapsrac1
                                  Filename           /saswork/SAS_work014A01900110_imapsrac1
                                  Inode Number       147496
                                  Access Permission  rwx------
                                  Owner Name         ssbuechl
                                  File Size (bytes)  256


                                                Member      File
                                 #  Name        Type        Size  Last Modified

                                 1  FINALDATA   DATA      966656  05May16:07:22:54
                                 2  QUERYDATA   DATA      966656  05May16:07:22:54
                                 3  QUERYRULES  DATA       73728  05May16:07:20:48
                                 4  SASMACR     CATALOG    12288  05May16:07:20:47
1   +                    MODIFY FinalData;
1   +                                          INDEX CREATE spm_calc_batch_date imb_code / UNIQUE NOMISS;
ERROR: Duplicate values not allowed on index SPM_CALC_BATCH_DATE for file FINALDATA.
ERROR: Duplicate values not allowed on index IMB_CODE for file FINALDATA.
1   +                                                                                                         run;

NOTE: Statements not processed because of errors noted above.

NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE DATASETS used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 May 2016 13:04:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-troubles-with-Indexes/m-p/268498#M53152</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-05-05T13:04:41Z</dc:date>
    </item>
    <item>
      <title>Re: More troubles with Indexes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-troubles-with-Indexes/m-p/268506#M53154</link>
      <description>a composite index is defined like&lt;BR /&gt;INDEX CREATE key=( firstVar secondVar) /unique ;</description>
      <pubDate>Thu, 05 May 2016 13:12:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-troubles-with-Indexes/m-p/268506#M53154</guid>
      <dc:creator>Peter_C</dc:creator>
      <dc:date>2016-05-05T13:12:57Z</dc:date>
    </item>
    <item>
      <title>Re: More troubles with Indexes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-troubles-with-Indexes/m-p/268511#M53155</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You are setting an index with the option unique, and it is telling you there are duplicate data in that column of data. &amp;nbsp;Remove the duplicates so the column is unique. &amp;nbsp;Also, why is the code in a macro, it doesn't appear to do anything other than add several lines to your code. &amp;nbsp;Also, please avoid all caps in coding:&lt;/P&gt;
&lt;PRE&gt;proc sort data=finaldata dupout=dups nodupkey;
  by spm_calc_batch_date;
run;&lt;/PRE&gt;
&lt;P&gt;The above will show you the duplicate rows of data.&lt;/P&gt;
&lt;P&gt;To quantify my comment on caps and no macro, this code is exactly the same as wht you do:&lt;/P&gt;
&lt;PRE&gt;proc datasets;
  modify finaldata;
  index create spm_calc_batch_date imb_code / unique nomiss;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 05 May 2016 13:27:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-troubles-with-Indexes/m-p/268511#M53155</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2016-05-05T13:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: More troubles with Indexes</title>
      <link>https://communities.sas.com/t5/SAS-Programming/More-troubles-with-Indexes/m-p/268516#M53158</link>
      <description>Thanks very much!</description>
      <pubDate>Thu, 05 May 2016 13:47:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/More-troubles-with-Indexes/m-p/268516#M53158</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-05-05T13:47:10Z</dc:date>
    </item>
  </channel>
</rss>

