<?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: ERROR: Duplicate values not allowed on index IMB_CODE for file FINALDATA. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Duplicate-values-not-allowed-on-index-IMB-CODE-for-file/m-p/268281#M53090</link>
    <description>&lt;P&gt;Check your dataset for duplicate values of IMB_CODE. You've stated it shouldn't have duplicates between runs, but can the first dataset have duplicates? If so that's not a unique index.&lt;/P&gt;</description>
    <pubDate>Wed, 04 May 2016 13:54:41 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2016-05-04T13:54:41Z</dc:date>
    <item>
      <title>ERROR: Duplicate values not allowed on index IMB_CODE for file FINALDATA.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Duplicate-values-not-allowed-on-index-IMB-CODE-for-file/m-p/268277#M53088</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi. &amp;nbsp;I have a macro that builds QueryData and appends it to FinalData repeatedly. &amp;nbsp;After the first append I want to build a unique index by imb_code to prevent the same imb_code from being appended to FinalData in future iterations.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm getting an error that seems to be failing the program and keeping the unique index from being created (I think):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ERROR: Duplicate values not allowed on index IMB_CODE for file FINALDATA.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know why I'm unable to create the unique index?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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 ;&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;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;* RULE QUERIES. Build and execute rule queries based on the rules defined in QueryRules (one at a time looping) ;
%macro BuildQueryData(analysis_desc= , rule= , rule_order= );

	proc sql;
	create table QueryData as 
	(       select %str(%')&amp;amp;analysis_desc.%str(%') as RULE_NM, 
			b.actual_dlvry_date as AD_DT, 
			b.imb_code, 
			&amp;amp;rule_order as rule_order
            from iv_ora.bi_spm_piece_recon a,  bids_ora.bi_spm_piece_recon b                                                                                                                                                                                                                                                                                                                                                                                                                                                   
            where a.imb_code = b.imb_code
            and &amp;amp;rule
	); 
	quit;

	* Append datasets to final dataset ;
	proc append base=FinalData
 	data=QueryData force;
	run;


	* Create unique index (if not exist), to meet the criteria that only one record (imb) per ;
	* rule is kept and counted in the data ;
	data _null_;
		set sashelp.vmember (where=(Libname='WORK' and memname='FINALDATA'));
		if upcase(index) = 'NO' then 
			do;
				put 'NO, INDEX DOES NOT EXIST!';
				call execute('%CreateUniqueIndex');
			end;
	RUN;

%mend BuildQueryData;&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_workAFDE01A901A4_imapsrac1
                                  Filename           /saswork/SAS_workAFDE01A901A4_imapsrac1
                                  Inode Number       147500
                                  Access Permission  rwx------
                                  Owner Name         ssbuechl
                                  File Size (bytes)  256


                                                Member       File
                                 #  Name        Type         Size  Last Modified

                                 1  FINALDATA   DATA      5292032  04May16:08:23:09
                                 2  QUERYDATA   DATA      5292032  04May16:08:23:08
                                 3  QUERYRULES  DATA        73728  04May16:08:20:26
                                 4  SASMACR     CATALOG     12288  04May16:08:20:26
1   +                    MODIFY FinalData;
1   +                                          INDEX CREATE imb_code / UNIQUE NOMISS;
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.01 seconds
      cpu time            0.01 seconds&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2016 13:49:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Duplicate-values-not-allowed-on-index-IMB-CODE-for-file/m-p/268277#M53088</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-05-04T13:49:59Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Duplicate values not allowed on index IMB_CODE for file FINALDATA.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Duplicate-values-not-allowed-on-index-IMB-CODE-for-file/m-p/268281#M53090</link>
      <description>&lt;P&gt;Check your dataset for duplicate values of IMB_CODE. You've stated it shouldn't have duplicates between runs, but can the first dataset have duplicates? If so that's not a unique index.&lt;/P&gt;</description>
      <pubDate>Wed, 04 May 2016 13:54:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Duplicate-values-not-allowed-on-index-IMB-CODE-for-file/m-p/268281#M53090</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-05-04T13:54:41Z</dc:date>
    </item>
    <item>
      <title>Re: ERROR: Duplicate values not allowed on index IMB_CODE for file FINALDATA.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ERROR-Duplicate-values-not-allowed-on-index-IMB-CODE-for-file/m-p/268287#M53091</link>
      <description>Yes, thank you!</description>
      <pubDate>Wed, 04 May 2016 14:06:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ERROR-Duplicate-values-not-allowed-on-index-IMB-CODE-for-file/m-p/268287#M53091</guid>
      <dc:creator>buechler66</dc:creator>
      <dc:date>2016-05-04T14:06:36Z</dc:date>
    </item>
  </channel>
</rss>

