/* --------------------------------------------------------------------------- $Revision: 1.1.2.2.2.2 $ $Date: 2015/05/26 08:56:39 $ NAME: cxt_ecvChkIntegrity.sas TYPE: DESCRIPTION: Sub-macro that confirms that CEA and SAS tables appear to be in sync. Not a thorough check, but a good check to make sure data is correct for when transform is being run for specific runModes. It also checks that the next_customer_dimension is not < the maximum existing customer-id. Uses &retVar from calling macro. SAS VERSION: 9.4 INPUT: +----------------------------------------------------------------- | Input Item Name: | Description: | Type: | Mode: | Validation: | Default: none | Other characteristics: OUTPUT: Specify data sets, files, reports, graphs, html, e-mail, pages, macro variables, slists, return codes, etc. +----------------------------------------------------------------- | Output Item Name: | Description: | Type: | Mode: CALLS: Specify external software units and how are they called (i.e. by macros, methods, frames, etc.). CALLED BY (optional): PRECONDITIONS (optional): POSTCONDITIONS (optional): HISTORY: userid yyyymmdd defectid desc keadam 20131017 S0946771 Programmatically converted all messaging to use sasmsg function. keadam 20150331 S1168163 Was using out of date messaging macro - look for the comments inline ------------------------------------------------------------------------------ Copyright (c) 2005-2015, SAS Institute Inc., Cary, NC, USA, All Rights Reserved ------------------------------------------------------------------------------ */ %macro cxt_ecvChkIntegrity( retVar=pIncChkIntRetVar /*Must be created first if specified. Returns OK or BAD.*/ ,runMode= /*Only used when called from the macro that processes the run files.*/ /*If values not set for these, it uses the system defaults*/ ,nextCustDimSourceSas= ,nextCustDimSourceCea= ,custDimSourceSAS= ); /*Macro that confirms that CEA and SAS tables appear to be in sync. Not a thorough check, but good enough. It also checks that the next_customer_dimension is not < the maximum existing customer-id.*/ %if &retVar ne %then %let &retVar=; %let integrityOK=;/*This is created outside the macro call, so functions as a return var.*/ *Establish macro variable names holding full libref.dataset; *names of the tables we need; %local tableMacNames; %let tableMacNames=; %if &nextCustDimSourceSas= %then %let tableMacNames=&tableMacNames permNextCustDimSource; %if &nextCustDimSourceCea= %then %let tableMacNames=&tableMacNames CEA_NextCustDimSource; %if &custDimSourceSAS= %then %let tableMacNames=&tableMacNames permCust_ProfileSource; %global &tableMacNames; %cxt_ecvGetTableNames(&tableMacNames) %if %cxt_ecvchkErr %then %goto badEnd; %if &nextCustDimSourceSas= %then %let nextCustDimSourceSas=&permNextCustDimSource; %if &nextCustDimSourceCea= %then %let nextCustDimSourceCea=&CEA_NextCustDimSource; %if &custDimSourceSAS= %then %let custDimSourceSAS=&permCust_ProfileSource; proc sql noprint; select "Y" into: integrityOk from &nextCustDimSourceSas s, &nextCustDimSourceCea c where s.next_customer_dimension=c.next_customer_dimension; quit; %if %cxt_ecvchkErr %then %goto badEnd; %if &integrityOK ne Y %then %do; /*%put ERR%str(OR:) Next customer-id not identical in both SAS and CEA tables: &nextCustDimSourceSas and &nextCustDimSourceCea..;*//*keadam 20131015 S0946771*/ /*keadam 20131015 S0946771*//*Replacement messaging call is below.*/ %put %sysfunc(sasmsg(&ecv_cxaMsgDset,_ecvERRORmsg_label,NOQUOTE)) %sysfunc(sasmsg(&ecv_cxaMsgDset,_cxaecv_dscheck_33_error,NOQUOTE,&nextCustDimSourceSas,&nextCustDimSourceCea.)); %if &runMode ne %then %do; /*Note, the macro var below just keeps track of the actual number of tables getting updated in this SAS session (whether or not successful.) This is initialized by the main CEA update job, and then incremented by the updateceatables macro. If this is the CEA update job running, and the two next_customer_dimension tables have a different value, AND no CEA tables were updated, then it suggests there was an earlier problem with this update. We globalize it here just in case, for some reason, it does not exist.*/ %global ecvCEAtableUpdateCount; %if &runMode=CEASASDONE and (&ecvCEAtableUpdateCount=0 or &ecvCEAtableUpdateCount=) %then /*%put ERR%str(OR:) Note also that although this is the CEA UPDATE run, no CEA tables were updated, which suggests a problem in this run.;*//*keadam 20131015 S0946771*/ /*keadam 20131015 S0946771*//*Replacement messaging call is below.*/ %put %sysfunc(sasmsg(&ecv_cxaMsgDset,_ecvERRORmsg_label,NOQUOTE)) %sysfunc(sasmsg(&ecv_cxaMsgDset,_cxaecv_match_49_error,NOQUOTE)); %goto badEnd; %end; %end; %local next_customer_dimension max_customer_dimension; %let next_customer_dimension=0; %let max_customer_dimension=0; proc sql noprint; select next_customer_dimension format=20. into: next_customer_dimension from &nextCustDimSourceSas; quit; %if %cxt_ecvchkErr %then %goto badEnd; proc sql noprint; select max(customer_sk) format=20. into: max_customer_dimension from &custDimSourceSAS; quit; %if %cxt_ecvchkErr %then %goto badEnd; %if &max_customer_dimension=. or &max_customer_dimension= %then %let max_customer_dimension=0; %if %eval(&next_customer_dimension-&max_customer_dimension)<=0 %then %do; /*keadam 20150331 S1168163*//*Below two statements replaced call to out of date messaging macro %msg from cxa_ecvProcessRunFiles macro.*/ %put %sysfunc(sasmsg(&ecv_cxaMsgDset,_ecvERRORmsg_label,NOQUOTE)) %sysfunc(sasmsg(&ecv_cxaMsgDset,_cxaecv_dscheck_48_error,NOQUOTE)); %goto badEnd; %end; %if &retVar ne %then %let &retVar=OK; %goto macEnd; %badEnd: %if &retVar ne %then %let &retVar=; %cxt_EcvChkRetVar(&retVar) %macEnd: %mend cxt_ecvChkIntegrity;