<?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 Need to conduct validation  for values appearing in a data table against a master table? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-to-conduct-validation-for-values-appearing-in-a-data-table/m-p/815814#M321987</link>
    <description>&lt;P&gt;I have 2 tables called collateral and collateral type master in an SQL server database which I'm accessing through SAS Enterprise guide&lt;/P&gt;&lt;P&gt;Both have two columns COLLATERAL_TYPE_CODE &amp;amp; COLLATERAL_SUB_TYPE_CODE , the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;combination&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of which i need to validate against entries in the master, and only for reporting date 31st December 2021 records&lt;/P&gt;&lt;P&gt;Eg - (COLLATERAL_TYPE_CODE, COLLATERAL_SUB_TYPE_CODE) = (70,70) , (70,701) , etc&lt;/P&gt;&lt;P&gt;The issue is that the data type for the fields should be numeric as per the data template but as per the structure (definition ? ) of the table in the database , only COLLATERAL_TYPE_CODE is numeric, as it should be, in the collateral table but the rest are character.&lt;/P&gt;&lt;P&gt;I need help with a query that can help me check out / validate the values appearing in the data table against the master&lt;/P&gt;&lt;P&gt;The code that i have tried till now&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;/*COLLATERAL_TYPE_CODE*/
/*COLLATERAL_SUB_TYPE_CODE*/



proc sql;
/*create table temp_1 as*/
select count(1)as cnt, COLLATERAL_TYPE_CODE
from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
group by COLLATERAL_TYPE_CODE
order by COLLATERAL_TYPE_CODE;
quit;



proc sql;
create table temp_1 as
select distinct (COLLATERAL_SUB_TYPE_CODE,COLLATERAL_TYPE_CODE)
from prcr.TB_IFRS9_COLLATERAL
where REPORTING_DATE in ("31DEC2021"d) ;
quit;



data temp_2;
set temp_1;
COLLATERAL_TYPE_CODE_1 = put(COLLATERAL_TYPE_CODE, best32.);
run;







proc sql;
create table coll_sub_type_code_in as
select * from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
where COLLATERAL_SUB_TYPE_CODE in (select COLLATERAL_SUB_TYPE_CODE from temp_1);
quit;
/*IN ---- NOTE: Table WORK.TEST_1 created, with 224 rows and 5 columns.*/



proc sql;
create table coll_sub_type_code_notin as
select * from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
where COLLATERAL_SUB_TYPE_CODE not in (select COLLATERAL_SUB_TYPE_CODE from temp_1);
quit;
/*NOT IN---NOTE: Table WORK.TEST_1 created, with 661 rows and 5 columns. */




/*Step:-2*/



proc sql;
create table coll_type_code_in as
select * from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
where COLLATERAL_TYPE_CODE in (select COLLATERAL_TYPE_CODE_1 from temp_2);
quit;



/*NOTE: Table WORK.COLL_TYPE_CODE_IN created, with 0 rows and 5 columns.*/



proc sql;
create table coll_type_code_notin as
select * from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
where COLLATERAL_TYPE_CODE in (select COLLATERAL_TYPE_CODE_1 from temp_2);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 31 May 2022 11:28:05 GMT</pubDate>
    <dc:creator>axel_p</dc:creator>
    <dc:date>2022-05-31T11:28:05Z</dc:date>
    <item>
      <title>Need to conduct validation  for values appearing in a data table against a master table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-conduct-validation-for-values-appearing-in-a-data-table/m-p/815814#M321987</link>
      <description>&lt;P&gt;I have 2 tables called collateral and collateral type master in an SQL server database which I'm accessing through SAS Enterprise guide&lt;/P&gt;&lt;P&gt;Both have two columns COLLATERAL_TYPE_CODE &amp;amp; COLLATERAL_SUB_TYPE_CODE , the&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;combination&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;of which i need to validate against entries in the master, and only for reporting date 31st December 2021 records&lt;/P&gt;&lt;P&gt;Eg - (COLLATERAL_TYPE_CODE, COLLATERAL_SUB_TYPE_CODE) = (70,70) , (70,701) , etc&lt;/P&gt;&lt;P&gt;The issue is that the data type for the fields should be numeric as per the data template but as per the structure (definition ? ) of the table in the database , only COLLATERAL_TYPE_CODE is numeric, as it should be, in the collateral table but the rest are character.&lt;/P&gt;&lt;P&gt;I need help with a query that can help me check out / validate the values appearing in the data table against the master&lt;/P&gt;&lt;P&gt;The code that i have tried till now&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;/*COLLATERAL_TYPE_CODE*/
/*COLLATERAL_SUB_TYPE_CODE*/



proc sql;
/*create table temp_1 as*/
select count(1)as cnt, COLLATERAL_TYPE_CODE
from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
group by COLLATERAL_TYPE_CODE
order by COLLATERAL_TYPE_CODE;
quit;



proc sql;
create table temp_1 as
select distinct (COLLATERAL_SUB_TYPE_CODE,COLLATERAL_TYPE_CODE)
from prcr.TB_IFRS9_COLLATERAL
where REPORTING_DATE in ("31DEC2021"d) ;
quit;



data temp_2;
set temp_1;
COLLATERAL_TYPE_CODE_1 = put(COLLATERAL_TYPE_CODE, best32.);
run;







proc sql;
create table coll_sub_type_code_in as
select * from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
where COLLATERAL_SUB_TYPE_CODE in (select COLLATERAL_SUB_TYPE_CODE from temp_1);
quit;
/*IN ---- NOTE: Table WORK.TEST_1 created, with 224 rows and 5 columns.*/



proc sql;
create table coll_sub_type_code_notin as
select * from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
where COLLATERAL_SUB_TYPE_CODE not in (select COLLATERAL_SUB_TYPE_CODE from temp_1);
quit;
/*NOT IN---NOTE: Table WORK.TEST_1 created, with 661 rows and 5 columns. */




/*Step:-2*/



proc sql;
create table coll_type_code_in as
select * from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
where COLLATERAL_TYPE_CODE in (select COLLATERAL_TYPE_CODE_1 from temp_2);
quit;



/*NOTE: Table WORK.COLL_TYPE_CODE_IN created, with 0 rows and 5 columns.*/



proc sql;
create table coll_type_code_notin as
select * from prcr.TB_IFRS9_COLLATERAL_TYPE_MAS
where COLLATERAL_TYPE_CODE in (select COLLATERAL_TYPE_CODE_1 from temp_2);
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 31 May 2022 11:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-conduct-validation-for-values-appearing-in-a-data-table/m-p/815814#M321987</guid>
      <dc:creator>axel_p</dc:creator>
      <dc:date>2022-05-31T11:28:05Z</dc:date>
    </item>
    <item>
      <title>Re: Need to conduct validation  for values appearing in a data table against a master table?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-to-conduct-validation-for-values-appearing-in-a-data-table/m-p/816739#M322406</link>
      <description>&lt;P&gt;Have you tried converting the variable type and a full join?&amp;nbsp; It would help if you could send a sample of the data sources.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;PROC SQL;&lt;BR /&gt;CREATE TABLE tablename AS &lt;BR /&gt;SELECT COLLATERAL_TYPE_CODE, INPUT(COLLATERAL_SUB_TYPE_CODE, COMMA20.) as COLLATERAL_SUB_TYPE_CODE&lt;BR /&gt;/* The input function is used to convert character to numeric */&lt;BR /&gt;FROM prcr.TB_IFRS9_COLLATERAL_TYPE_MAS as T1&lt;BR /&gt;FULL JOIN prcr.TB_IFRS9_COLLATERAL as t2&lt;/P&gt;
&lt;P&gt;ON (t1.COLLATERAL_TYPE_CODE = t2.COLLATERAL_SUB_TYPE_CODE);&lt;BR /&gt;QUIT;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jun 2022 19:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-to-conduct-validation-for-values-appearing-in-a-data-table/m-p/816739#M322406</guid>
      <dc:creator>JOL</dc:creator>
      <dc:date>2022-06-06T19:53:37Z</dc:date>
    </item>
  </channel>
</rss>

