<?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 integrity constraints to an existing data set in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/integrity-constraints-to-an-existing-data-set/m-p/581777#M165393</link>
    <description>&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and I am using SAS university edition and I am trying to set integrity constraints to an existing data set that has one observation violates one of the constraints. But the code does not complete because of this error ( &lt;SPAN&gt;ERROR: Integrity constraint Low_ck was rejected because 1 observations failed the constraint&lt;/SPAN&gt;&lt;SPAN&gt;. ) please find the code below.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My goal from this code is to make sure that the data set meets all the constraints and if not, a way or a report identifying which observations don't meet them and which one. I can do it but I have to create an empty data set and append this data set to it then I can get the report by the audit file, can I do it without the empty data set method?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc datasets library=pg1 nolist;
modify NYSE_test;
ic create Symbol_pk = primary key(Symbol)
message = "Symbol must be unique and non-missing"
msgtype = user;

ic create Open_ck = check(where=(Open is not missing))
message = "Open price must not missing"
msgtype = user;

ic create Close_ck = check(where=( Close between Low and High ))
message = "Close price must not missing or not between L and H"
msgtype = user;

ic create Low_ck = check(where=(Low is not missing))
message = "Low price must not missing"
msgtype = user;

ic create High_ck = check(where=(High is not missing))
message = "High price must not missing"
msgtype = user;

run;

audit NYSE_test;
initiate;
run;
quit;

title "Integrity Constraint Violations";
proc report data=pg1.NYSE_test(type=audit);
where _ATOPCODE_ in ('EA' 'ED' 'EU');
columns Symbol Date Open Low High Close Volume _ATMESSAGE_;
define  _atmessage_ / display "_Error Report_"
width=30 flow;
run;&lt;/PRE&gt;&lt;P&gt;thank you so much in advance,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Mohamed Elfakhfakh&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Aug 2019 16:49:57 GMT</pubDate>
    <dc:creator>Elfakhfakh</dc:creator>
    <dc:date>2019-08-16T16:49:57Z</dc:date>
    <item>
      <title>integrity constraints to an existing data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/integrity-constraints-to-an-existing-data-set/m-p/581777#M165393</link>
      <description>&lt;P&gt;Hello all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS and I am using SAS university edition and I am trying to set integrity constraints to an existing data set that has one observation violates one of the constraints. But the code does not complete because of this error ( &lt;SPAN&gt;ERROR: Integrity constraint Low_ck was rejected because 1 observations failed the constraint&lt;/SPAN&gt;&lt;SPAN&gt;. ) please find the code below.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;My goal from this code is to make sure that the data set meets all the constraints and if not, a way or a report identifying which observations don't meet them and which one. I can do it but I have to create an empty data set and append this data set to it then I can get the report by the audit file, can I do it without the empty data set method?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc datasets library=pg1 nolist;
modify NYSE_test;
ic create Symbol_pk = primary key(Symbol)
message = "Symbol must be unique and non-missing"
msgtype = user;

ic create Open_ck = check(where=(Open is not missing))
message = "Open price must not missing"
msgtype = user;

ic create Close_ck = check(where=( Close between Low and High ))
message = "Close price must not missing or not between L and H"
msgtype = user;

ic create Low_ck = check(where=(Low is not missing))
message = "Low price must not missing"
msgtype = user;

ic create High_ck = check(where=(High is not missing))
message = "High price must not missing"
msgtype = user;

run;

audit NYSE_test;
initiate;
run;
quit;

title "Integrity Constraint Violations";
proc report data=pg1.NYSE_test(type=audit);
where _ATOPCODE_ in ('EA' 'ED' 'EU');
columns Symbol Date Open Low High Close Volume _ATMESSAGE_;
define  _atmessage_ / display "_Error Report_"
width=30 flow;
run;&lt;/PRE&gt;&lt;P&gt;thank you so much in advance,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Mohamed Elfakhfakh&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 16:49:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/integrity-constraints-to-an-existing-data-set/m-p/581777#M165393</guid>
      <dc:creator>Elfakhfakh</dc:creator>
      <dc:date>2019-08-16T16:49:57Z</dc:date>
    </item>
    <item>
      <title>Re: integrity constraints to an existing data set</title>
      <link>https://communities.sas.com/t5/SAS-Programming/integrity-constraints-to-an-existing-data-set/m-p/581820#M165411</link>
      <description>&lt;P&gt;you have to fix the record that doesn't meet you constrants.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ic create Low_ck = check(where=(Low is not missing))
message = "Low price must not missing"
msgtype = user;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you data has 1 record with missing low price.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2019 18:33:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/integrity-constraints-to-an-existing-data-set/m-p/581820#M165411</guid>
      <dc:creator>VDD</dc:creator>
      <dc:date>2019-08-16T18:33:56Z</dc:date>
    </item>
  </channel>
</rss>

