<?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: Dynamic code for data validation on multiple datasets in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597308#M172087</link>
    <description>I want to do the validation checks for 10 datasets and I have 70 validation&lt;BR /&gt;checks all together  to perform on those tables.&lt;BR /&gt;&lt;BR /&gt;Yes, I tried to execute %error_xxxx irrespective of the table.&lt;BR /&gt;&lt;BR /&gt;Could you please help me how to control %error_xxxxx based on the source&lt;BR /&gt;dataset?&lt;BR /&gt;</description>
    <pubDate>Thu, 17 Oct 2019 13:12:14 GMT</pubDate>
    <dc:creator>David_Billa</dc:creator>
    <dc:date>2019-10-17T13:12:14Z</dc:date>
    <item>
      <title>Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597013#M171994</link>
      <description>&lt;P&gt;I've written the code for data validation for one dataset. I would like to develop further for multiple datasets using macro. Now the problem is that the rules which I want to write is not applicable for all the datasets. Because the variables for each dataset is not same.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I want to develop the below code to handle all the rules for multiple datasets. I want to feed the dataset name and variable names as keyword parameter macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  infile cards dsd dlm='|' truncover;
  input FLT_LAYR_NM :$10. FYP_NM :$30. _TEAM_NM :$30. ;
cards;
DIS|Consistencycheck|Business
DID|Rangecheck|Client
DID| |Client
DID|Rangecheck|Employee
;

data want;
  length Error_id 8	Error_record $200;
  keep Error_id	Error_record ;
  set have ;
  Error_record=cats(FLT_LAYR_NM,'|',FYP_NM,'|',_TEAM_NM);

  Error_id=1001;
  if missing(FYP_NM) then output;

  Error_id=1002;
  if _TEAM_NM not in ('Business','Employee') then output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;U&gt;SAS code or something similar which I except:&lt;/U&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the challenge here is I want to skip the condition (or data validation) in case if the variable not exists in the calling macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro data_validation(table_name,variable1,variable2,variable3,variable4)
data have;
  infile cards dsd dlm='|' truncover;
  input FLT_LAYR_NM :$10. FYP_NM :$30. _TEAM_NM :$30. ;
cards;
DIS|Consistencycheck|Business
DID|Rangecheck|Client
DID| |Client
DID|Rangecheck|Employee
;

data want;
  length Error_id 8	Error_record $200;
  keep Error_id	Error_record ;
  set &amp;amp;table_name;
  Error_record=cats(FLT_LAYR_NM,'|',FYP_NM,'|',_TEAM_NM);

/*data validation rule for variable 1*/
  Error_id=1001;
  if missing(&amp;amp;variable1) then output;

/*data validation rule for variable 2*/
  Error_id=1002;
  if &amp;amp;variable2 not in ('Business','Employee') then output;
run;

/*data validation rule for variable 3*/

Error_id=1003;
  if &amp;amp;variable3  not in ('Bus','Train') then output;
run;

/*data validation rule for variable 4*/

Error_id=1004;
  if &amp;amp;variable4  not in ('Hotel','Office') then output;
run;

%mend data_validation;

%data_validation(table_name,variable1,variable4)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Oct 2019 18:07:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597013#M171994</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-16T18:07:56Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597031#M171996</link>
      <description>&lt;P&gt;You could do something like this and pass in the error checks as macros for each table that you want:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro err_1001(var);
	Error_id=1001;
	if missing(&amp;amp;var.) then output;
%mend;


%macro err_1002(var);
	Error_id=1002;
    if &amp;amp;var. not in ('Business','Employee') then output;
%mend;

%macro data_validation;
	data want;
	  length Error_id 8	Error_record $200;
	  keep Error_id	Error_record ;
	  set have ;
	  Error_record=cats(FLT_LAYR_NM,'|',FYP_NM,'|',_TEAM_NM);

	  /*Error_id=1001;
	  if missing(FYP_NM) then output;*/
	  %err_1001(FYP_NM)

	  /*Error_id=1002;
	  if _TEAM_NM not in ('Business','Employee') then output;*/
	  %err_1002(_TEAM_NM);

	run;
%mend;
%data_validation;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;You could place all your individual error checks in separate sas files, a control file that's read in each time, or just one large sas file. Of course you can automate passing in your tables and variables as desired.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 18:55:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597031#M171996</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-10-16T18:55:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597033#M171997</link>
      <description>&lt;P&gt;So you want to test whether variable1, (or 2 or 3 or 4) exists in table_name, and run the value check only if it in the data set - is that right?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What you can do in put a list of all the TABLE_NAME variables in a macrovar (CSV_VARNAMES), and then do a check on whether VARIABLE1 is found in that list.&amp;nbsp; If it's not then reset it to blank.&amp;nbsp; Later on you can test only if it's not blank.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So prior to your DATA WANT step you can:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;  proc sql noprint;
    select distinct upcase(name) into :csv_varnames separated by ' '
    from dictionary.columns where libname="&amp;amp;dslib" and memname="&amp;amp;dsname";
  quit;

  %do i=1 %to 4;
    %let variable&amp;amp;i=%upcase(&amp;amp;&amp;amp;variable&amp;amp;i);
    %if %sysfunc(findw(&amp;amp;csv_varnames,&amp;amp;&amp;amp;variable&amp;amp;i))=0 %then %let variable&amp;amp;i=%str();
  %end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then inside the DATA WANT step you can have:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%if &amp;amp;variable1 ^= %str() %then %do;
    /*data validation rule for variable 1*/
    Error_id=1001;
    if missing(&amp;amp;variable1) then output;
%end;

etc, for varibles2, 3, and 4&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 18:53:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597033#M171997</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-16T18:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597194#M172061</link>
      <description>&lt;P&gt;I tried your code as follows. But in the macro %&lt;CODE class=" language-sas"&gt;err_1004&lt;/CODE&gt; I tried to pass the unknown variable (new_variable)&amp;nbsp;as value and in that case I want the program to skip that macro as the unknown variable (new_variable)&amp;nbsp;is not vailable in source dataset (HAVE).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So objective is in case if the passing variable is not avilable in the source dataset then I don't that macro to execute.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*source dataset*/
data have;
  infile cards dsd dlm='|' truncover;
  input FLT_LAYR_NM :$10. FYP_NM :$30. _TEAM_NM :$30. ;
cards;
DIS|Consistencycheck|Business
DID|Rangecheck|Client
DID| |Client
DID|Rangecheck|Employee
;
run;

/*check1*/
%macro err_1001(var);
	Error_id=1001;
	if missing(&amp;amp;var.) then output;
%mend;

/*check2*/
%macro err_1002(var);
	Error_id=1002;
    if &amp;amp;var. not in ('Business','Employee') then output;
%mend;

/*check3*/
%macro err_1004(var);
	Error_id=1003;
    if &amp;amp;var. not in ('Business','Employee') then output;
%mend;

/*dynamic macro program*/
%macro data_validation;
	data want;
	  length Error_id 8	Error_record $200;
	  keep Error_id	Error_record ;
	  set have ;
	  Error_record=cats(FLT_LAYR_NM,'|',FYP_NM,'|',_TEAM_NM);

	  %err_1001(FYP_NM)

	  %err_1002(_TEAM_NM); 
	

      /*test macro*/
	  %err_1004(new_variable); /*new_variable is not available in the source dataset*/

	run;
%mend;

%data_validation;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Output which I got is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="348"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="134"&gt;&lt;STRONG&gt;Error_id&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="214"&gt;&lt;STRONG&gt;Error_record&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1003&lt;/TD&gt;
&lt;TD&gt;DIS|Consistencycheck|Business&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1002&lt;/TD&gt;
&lt;TD&gt;DID|Rangecheck|Client&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1003&lt;/TD&gt;
&lt;TD&gt;DID|Rangecheck|Client&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1001&lt;/TD&gt;
&lt;TD&gt;DID||Client&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1002&lt;/TD&gt;
&lt;TD&gt;DID||Client&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1003&lt;/TD&gt;
&lt;TD&gt;DID||Client&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1003&lt;/TD&gt;
&lt;TD&gt;DID|Rangecheck|Employee&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Desired Output,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE width="210"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="72"&gt;&lt;STRONG&gt;Error_id&lt;/STRONG&gt;&lt;/TD&gt;
&lt;TD width="138"&gt;&lt;STRONG&gt;Error_record&lt;/STRONG&gt;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1002&lt;/TD&gt;
&lt;TD&gt;DID|Rangecheck|Client&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1001&lt;/TD&gt;
&lt;TD&gt;DID||Client&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;1002&lt;/TD&gt;
&lt;TD&gt;DID||Client&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Thu, 17 Oct 2019 06:45:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597194#M172061</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-17T06:45:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597217#M172072</link>
      <description>&lt;P&gt;To answer your question,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you want to test whether variable1, (or 2 or 3 or 4) exists in table_name, and run the value check only if it in the data set - is that right? - &lt;STRONG&gt;yes&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please help me understand how to pass the Input to the below macro variables? Also I would like to why you've creating macro variable 'i'&amp;nbsp;only till 4. Instead of hard coding can we find the dynmaic way to handle this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; %do i=1 %to 4;
    %let variable&amp;amp;i=%upcase(&amp;amp;&amp;amp;variable&amp;amp;i);
    %if %sysfunc(findw(&amp;amp;csv_varnames,&amp;amp;&amp;amp;variable&amp;amp;i))=0 %then %let variable&amp;amp;i=%str();
  %end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;What I tried is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro validation(variable1,variable2,variable3);
  data _null_;
  %do i=1 %to 4;
    %let variable&amp;amp;i=%upcase(&amp;amp;&amp;amp;variable&amp;amp;i);
    %if %sysfunc(findw(&amp;amp;csv_varnames,&amp;amp;&amp;amp;variable&amp;amp;i))=0 %then %let variable&amp;amp;i=%str();
  %end;
  run;
  %mend;
%validation;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Error message is,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;SYMBOLGEN:  Macro variable I resolves to 4
MLOGIC(VALIDATION):  %LET (variable name is VARIABLE4)
SYMBOLGEN:  &amp;amp;&amp;amp; resolves to &amp;amp;.
SYMBOLGEN:  Macro variable I resolves to 4
WARNING: Apparent symbolic reference VARIABLE4 not resolved.
WARNING: Apparent symbolic reference VARIABLE4 not resolved.
ERROR: The text expression &amp;amp;VARIABLE4 contains a recursive reference to the macro variable VARIABLE4.  The macro variable will be 
       assigned the null value.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 09:35:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597217#M172072</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-17T09:35:37Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597304#M172085</link>
      <description>&lt;P&gt;I see. How many tables are you trying to apply this logic to? Are you trying to apply every %error_xxx check to every dataset regardless of the variables in each dataset? Here's a few options:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Manually control which %error_xxx checks are executed for each table (i.e. just don't include %err_1004 if you know the variable doesn't exist for this table). If you have a small number of tables, I would do this.&lt;/P&gt;&lt;P&gt;2. Add a step before where you dynamically determine if a given table has the variables of interest, then use macros to create the call for each %err_xxx check. If you have a large number of tables consider this.&lt;/P&gt;&lt;P&gt;3. Last, I have code that checks to see if a var is in the current dataset during datastep processing using, but it is not efficient and I would rather you go with one of the first two options.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 12:57:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597304#M172085</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-10-17T12:57:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597308#M172087</link>
      <description>I want to do the validation checks for 10 datasets and I have 70 validation&lt;BR /&gt;checks all together  to perform on those tables.&lt;BR /&gt;&lt;BR /&gt;Yes, I tried to execute %error_xxxx irrespective of the table.&lt;BR /&gt;&lt;BR /&gt;Could you please help me how to control %error_xxxxx based on the source&lt;BR /&gt;dataset?&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Oct 2019 13:12:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597308#M172087</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-17T13:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597378#M172110</link>
      <description>&lt;P&gt;This is pretty simple and I think will work:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Get a list of all the columns in your current table and save them into a macro:&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;proc sql noprint;
	select upcase(name) into :fields separated by ","
	from dictionary.columns
	where libname = "SASHELP" and memname = "CARS";
run;&lt;BR /&gt;&lt;BR /&gt;*test;&lt;BR /&gt;%put fields= &amp;amp;fields;&lt;BR /&gt;&amp;gt;&amp;gt;fields= MAKE,MODEL,TYPE,ORIGIN,DRIVETRAIN,MSRP,INVOICE,ENGINESIZE,CYLINDERS,HORSEPOWER,MPG_CITY,MPG_HIGHWAY,WEIGHT,WHEELBASE,LENGTH&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Pass in your libname and memname values as macros.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Add this IF check to each of your individual %err_xxx checks:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro err_1004(var);
	if upcase(vname(var)) in ("&amp;amp;fields") then do;
	    Error_id=1003;
	    if &amp;amp;var. not in ('Business','Employee') then output;
	end;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This way, if your current var isn't in the table (i.e. the list of values in &amp;amp;fields), the check won't run.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does that make sense?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro err_1004(var);
	if upcase(vname(var)) in ("&amp;amp;fields") then do;
		Error_id=1003;
	    if &amp;amp;var. not in ('Business','Employee') then output;
	end;
%mend;

%macro data_validation;
	proc sql noprint;
		select upcase(name) into :fields separated by ","
		from dictionary.columns
		where libname = "SASHELP" and memname = "CARS";
	run;

	data want;
	  length Error_id 8	Error_record $200;
	  keep Error_id	Error_record ;
	  set have ;
	  Error_record=cats(FLT_LAYR_NM,'|',FYP_NM,'|',_TEAM_NM);

	  %err_1004(new_field)

	run;
%mend;
%data_validation;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note, this is very similar to&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;'s solution. mkeintz's may be more efficient if your data is large since you won't check the list of fields for each datastep pass.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 15:09:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597378#M172110</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-10-17T15:09:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597390#M172120</link>
      <description>&lt;P&gt;Presumably you want to call the validation macro with arguments, much as in your original post.&amp;nbsp; Something link&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%data_validation(sashelp.class,age,height,xx,yy);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Invoking your original macro with the arguments above, and&amp;nbsp; modified as per my suggestion, should discover variables age and height in dataset sashelp.class - and process those variables per your code.&amp;nbsp; &amp;nbsp;It won't discover xx or yy, so no code for variable3 or variable4 will be executed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 15:23:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597390#M172120</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2019-10-17T15:23:53Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597408#M172133</link>
      <description>Thanks.I understand that I have to create macros for each validation check.&lt;BR /&gt;My question is how will you know which macro (validation check macros which&lt;BR /&gt;we create prior) to call in %data_validation macro? Because if we call all&lt;BR /&gt;the data validation macros then we end up with error as all the variables&lt;BR /&gt;will not be available in the source dataset.&lt;BR /&gt;&lt;BR /&gt;I would like to call the validation check macro (not all) which is valid&lt;BR /&gt;for the dataset which I'm going to put as source.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Oct 2019 16:05:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597408#M172133</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-17T16:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597434#M172139</link>
      <description>&lt;P&gt;If you put safety checks in place, which we have, then you can call all the %err_xxx macros for every table even if the table does not have the specified variables, which I thought is what you wanted. The safety checks won't execute the error check if the field isn't in the table (the macros will still execute, but the IF logic will prevent the error logic from running). This means you can call all the checks for every table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does this make sense?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 16:51:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597434#M172139</guid>
      <dc:creator>noling</dc:creator>
      <dc:date>2019-10-17T16:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamic code for data validation on multiple datasets</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597436#M172141</link>
      <description>Thanks,  it does makes sense to me. Yes, you understood correctly on the&lt;BR /&gt;requirement.&lt;BR /&gt;&lt;BR /&gt;Let me execute your code which has 'safety checks' which you posted in your&lt;BR /&gt;previous post and come back to you.&lt;BR /&gt;&lt;BR /&gt;If you find other way to achieve this task then let me know. Because I'm&lt;BR /&gt;worried about multiple IF clause being executed as I have 70+ validations&lt;BR /&gt;in real life.&lt;BR /&gt;</description>
      <pubDate>Thu, 17 Oct 2019 17:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Dynamic-code-for-data-validation-on-multiple-datasets/m-p/597436#M172141</guid>
      <dc:creator>David_Billa</dc:creator>
      <dc:date>2019-10-17T17:00:14Z</dc:date>
    </item>
  </channel>
</rss>

