<?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: Validate multipe tablename and Error handling using sas macro in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897574#M354694</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410614"&gt;@varshabansal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="I have this type of excel" style="width: 827px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88687i23502C5E2D12DD35/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="I have this type of excel" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;I have this type of excel&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you have the information in DATA already?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you writing MACRO code to check the data?&lt;/P&gt;
&lt;P&gt;Write SAS code instead.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Oct 2023 12:54:39 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2023-10-06T12:54:39Z</dc:date>
    <item>
      <title>Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897354#M354593</link>
      <description>&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;STRONG&gt;I have&lt;SPAN class=""&gt;&amp;nbsp;a&lt;/SPAN&gt;&amp;nbsp;main code file and macro code file and multiple tables and&amp;nbsp;&lt;SPAN class=""&gt;I&lt;/SPAN&gt;&amp;nbsp;want to validate the table _name&amp;nbsp;&lt;SPAN class=""&gt;and the same&lt;/SPAN&gt;&amp;nbsp;for column names, should be alphabets and underscore only by using macro and with do loop and I want that when&amp;nbsp;&lt;SPAN class=""&gt;I&lt;/SPAN&gt;&amp;nbsp;call my macro in&lt;SPAN class=""&gt;&amp;nbsp;the&lt;/SPAN&gt;&amp;nbsp;main file, if error occurs it generate error code and return&amp;nbsp;&lt;SPAN class=""&gt;code&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&lt;STRONG&gt;&amp;nbsp;to macro code&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;&lt;SPAN&gt;Main code-&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;/*******import mapping excel file********/
 proc import datafile="/home/viadmin/casuser/mapping.xlsx"
 out= work.mapping
 dbms=xlsx
 replace;
 sheet=sheet1;
 run;

/* update bank_key value */
data mapping;
set mapping;
if target_column='bank_key'
then mapping='0';
if target_column='change_begin_date' then mapping='%SYSFUNC(DATETIME())';
if target_column='change_end_date' then mapping="'01JAN5999:00:00:00'DT";
if target_column='current_ind' then mapping='"Y"';
if target_column = "bank_status_desc" then delete;
run;
/**create list of source and target tables to be loaded***/ 

proc sql;
    select distinct source_table into:source_table
    from mapping
    where source_table is not null;
run;
%put &amp;amp;source_table;

proc sql;
    select distinct target_table, mapping, target_column,count(*) 
        into :target_table,
        :mapping_func separated by ' ' ,
        :trgt_col separated by ' ',
        :count
    from mapping;
run;

%check_table;

%createTable;

proc sql ;
      select compress(put(max(BANK_KEY), best32.))
         into :etls_maxkey
        from amlcore.&amp;amp;target_table;
      quit;

/* %scdType2Loader; */&lt;/PRE&gt;&lt;P&gt;Macro code&lt;/P&gt;&lt;PRE&gt;%macro check_table;
  /* Check if the table name is empty. */
  %if (&amp;amp;source_table.="" ) %then 
    %do;
        %put "Error: Table name cannot be empty.";
        %return;
    %end;

  /* Check if the table name contains any special characters. */
  %let i = 1;
  %let l=%length(&amp;amp;source_table.);

  %do i=1 %to &amp;amp;l.;
    /* Check if the current character is a letter or underscore. */
    %if %substr(&amp;amp;source_table., &amp;amp;i, 1) ne " " 
    and %substr(&amp;amp;source_table., &amp;amp;i, 1) ne "_" 
    and %substr(&amp;amp;source_table., &amp;amp;i, 1) ne "." 
    and  %substr(&amp;amp;source_table., &amp;amp;i, 1) ne "0-9 "
    and %substr(&amp;amp;source_table., &amp;amp;i, 1) ne "$/,!@#%^&amp;amp;*" 
    %then %do;
      %put "Error: Table name can only contain letters and underscores.";
      %return;
    %end;
    %let i = &amp;amp;i + 1;
  %end;
   
  /* The table name is valid. */
  %put "Table name is valid.";
%mend check_table;

 %check_table;&lt;/PRE&gt;&lt;P&gt;Error: also shows error that table name contains underscore and alphabets&lt;/P&gt;&lt;P&gt;Error: error in %do I loop&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 12:04:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897354#M354593</guid>
      <dc:creator>varshabansal</dc:creator>
      <dc:date>2023-10-05T12:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897365#M354601</link>
      <description>&lt;P&gt;What does "validate" mean in this context?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are macros and do-loops required? Why couldn't another solution be used here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is wrong with the code you show?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please, some of us refuse to download attachments from internet web sites. Please include your code as text by copying the text and pasting it into the "code box" that appears when you click on the little running man icon.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 11:42:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897365#M354601</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-05T11:42:44Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897367#M354603</link>
      <description>Validate means- i want to check that table name contains only alphabets and&lt;BR /&gt;underscore&lt;BR /&gt;&lt;BR /&gt;Macros and do loop are included because i have multiple table name. So for&lt;BR /&gt;all table name i want to check that condition rule of alphabet and&lt;BR /&gt;underscore.&lt;BR /&gt;</description>
      <pubDate>Thu, 05 Oct 2023 11:50:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897367#M354603</guid>
      <dc:creator>varshabansal</dc:creator>
      <dc:date>2023-10-05T11:50:54Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897371#M354606</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410614"&gt;@varshabansal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Validate means- i want to check that table name contains only alphabets and&lt;BR /&gt;underscore&lt;BR /&gt;&lt;BR /&gt;Macros and do loop are included because i have multiple table name. So for&lt;BR /&gt;all table name i want to check that condition rule of alphabet and&lt;BR /&gt;underscore.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;What table names are you talking about? Do you mean SAS data set names? Or some other type of table names? Please be specific.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macros and do loop do not seem to be necessary, why do you insist on macros and loops? If there is a solution without macros and without do loops, we will likely provide that.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 12:00:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897371#M354606</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-05T12:00:06Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897373#M354608</link>
      <description>I have an excel file which contains different headers for table name, column name like these and there are multiple table name or you can say dataset name so i want to check for that and dataset contains different columnname also .</description>
      <pubDate>Thu, 05 Oct 2023 12:14:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897373#M354608</guid>
      <dc:creator>varshabansal</dc:creator>
      <dc:date>2023-10-05T12:14:49Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897377#M354611</link>
      <description>&lt;P&gt;Please import the Excel file into a SAS data set, and then a portion of that SAS data set with as working SAS data step code (&lt;A href="https://blogs.sas.com/content/sastraining/2016/03/11/jedi-sas-tricks-data-to-data-step-macro/" target="_self"&gt;examples and instructions&lt;/A&gt;) and then share that code with us. We cannot work with Excel files.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 12:24:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897377#M354611</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-10-05T12:24:44Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897392#M354619</link>
      <description>&lt;P&gt;Code like below could do or at least hopefully provide you with enough pointers to amend the code to what you need.&lt;BR /&gt;- Code amended replacing RegEx with function nvalid() as proposed by Tom.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.'class.2'n;
  set sashelp.class;
  length '9new_var'n 8;
  length '$$ $a'n 8;
  length 'a'n 8;
run;

%macro check(lref, tbl);
  data _null_;
    set sashelp.vcolumn(where=(libname=%upcase("&amp;amp;lref") and memname=%upcase("&amp;amp;tbl"))) end=last;

    if _n_=1 then
      do;
        if not nvalid(memname,'v7') then 
          do;
            putlog "Table name " memname "does not conform with SAS naming conventions";
            check_fail_cnt+1;
          end;
      end;
    if not nvalid(name,'v7') then 
      do;
        putlog "Variable name " name "does not conform with SAS naming conventions";
        check_fail_cnt+1;
      end;

    if last then 
      do;
        if check_fail_cnt&amp;gt;0 then
          do;
            /* and here you do whatever you like - abort the job, populate some macro variable etc. */
            putlog "Issues foundin table &amp;amp;lref..&amp;amp;tbl.. Aborting Job!!";
            abort cancel;
          end;
        else
          do;
            putlog "NO issues found in table &amp;amp;lref..&amp;amp;tbl";
          end;
      end;
  run;
%mend;

%check(sashelp, class);
%check(work, class.2);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;And if you've got some driver Excel that you want to use to call the macro then below one way how to do this.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data driver;
  infile datalines truncover dsd;
  input lref:$8. tbl:$32.;
  datalines;
sashelp,class
work,class.2
;

data _null_;
  set driver;
  call execute( cats('%check(',lref,',',tbl,')') );
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 13:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897392#M354619</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-05T13:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897394#M354621</link>
      <description>&lt;P&gt;If you want to test if a string is a valid SAS name then just use the NVALID() function.&amp;nbsp; If you want to it in macro code then use the %SYSFUNC() macro function to call the NVALID() function.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to test whether DATA is valid as SAS names then do not first convert the DATA into macro variables.&amp;nbsp; Test the DATA in a SAS code.&amp;nbsp; Then if there is some reason to convert some of the data into macro variables you can do that later.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 13:18:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897394#M354621</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-05T13:18:30Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897395#M354622</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;Ah, yes, nvalid()&lt;/P&gt;
&lt;P&gt;Forgot the function name and when I searched through the docu got confused with notname() which doesn't quite cut it which is why I've used a RegEx.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Oct 2023 13:25:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897395#M354622</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-05T13:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897530#M354670</link>
      <description>&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; memname should only contain alphabets and underscore not any number but here script allows for numbers also.</description>
      <pubDate>Fri, 06 Oct 2023 04:46:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897530#M354670</guid>
      <dc:creator>varshabansal</dc:creator>
      <dc:date>2023-10-06T04:46:52Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897534#M354674</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410614"&gt;@varshabansal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; memname should only contain alphabets and underscore not any number but here script allows for numbers also.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Digits are valid in SAS tables names - but o.k. if you only want to allow letters and the underscore then it's back to a regular expression.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro check(lref, tbl);
  data _null_;
    set sashelp.vcolumn(where=(libname=%upcase("&amp;amp;lref") and memname=%upcase("&amp;amp;tbl"))) end=last;

    if _n_=1 then
      do;
        if not prxmatch('/^[_[:alpha:]]{1,32} *$/',memname) then 
          do;
            putlog "Table name " memname "does not conform with SAS naming conventions";
            check_fail_cnt+1;
          end;
      end;
    if not nvalid(name,'v7') then 
      do;
        putlog "Variable name " name "does not conform with SAS naming conventions";
        check_fail_cnt+1;
      end;

    if last then 
      do;
        if check_fail_cnt&amp;gt;0 then
          do;
            /* and here you do whatever you like - abort the job, populate some macro variable etc. */
            putlog "Issues foundin table &amp;amp;lref..&amp;amp;tbl.. Aborting Job!!";
            abort cancel;
          end;
        else
          do;
            putlog "NO issues found in table &amp;amp;lref..&amp;amp;tbl";
          end;
      end;
  run;
%mend;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Oct 2023 05:31:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897534#M354674</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-06T05:31:18Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897541#M354677</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="I have this type of excel" style="width: 827px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88687i23502C5E2D12DD35/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="I have this type of excel" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;I have this type of excel&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 06:16:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897541#M354677</guid>
      <dc:creator>varshabansal</dc:creator>
      <dc:date>2023-10-06T06:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897542#M354678</link>
      <description>&lt;P&gt;That looks like a mapping sheet to support design and implementation of DM processes to load AML core tables. Not sure what this has to do with your initial question.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 06:23:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897542#M354678</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-06T06:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897543#M354679</link>
      <description>Yes, this is mapping sheet, from this I want to load this table and then extract these table name and column name from source and target and then check for naming convention after that we will perform all etl process for scd and so on.&lt;BR /&gt;</description>
      <pubDate>Fri, 06 Oct 2023 06:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897543#M354679</guid>
      <dc:creator>varshabansal</dc:creator>
      <dc:date>2023-10-06T06:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897545#M354681</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410614"&gt;@varshabansal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Yes, this is mapping sheet, from this I want to load this table and then extract these table name and column name from source and target and then check for naming convention after that we will perform all etl process for scd and so on.&lt;BR /&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The sample code I've provided for the driver table just needs the libref and table name.&lt;/P&gt;
&lt;P&gt;You should know the libref (staging, core?) and you've got the table name already in your Excel so shouldn't be hard to create this driver table. ...or you could also amend the macro provided slightly and use the mapping table as input.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 06:42:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897545#M354681</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2023-10-06T06:42:32Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897546#M354682</link>
      <description>&lt;P&gt;The first possible issue I see is here:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data mapping;
set mapping;
if target_column='bank_key'
then mapping='0'; /* if variable mapping is not already contained in dataset mapping,
it will be defined as character with a length of 1, leading to truncation later */
if target_column='change_begin_date' then mapping='%SYSFUNC(DATETIME())';
if target_column='change_end_date' then mapping="'01JAN5999:00:00:00'DT";
if target_column='current_ind' then mapping='"Y"';
if target_column = "bank_status_desc" then delete;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
    select distinct source_table into:source_table
    from mapping
    where source_table is not null;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;will not create a list, only one value will make it into the macro variable; use the SEPARATED BY option to get a list of values.&lt;/P&gt;
&lt;P&gt;SQL statements are executed immediately, so no RUN is needed. Properly terminate the SQL procedure with a QUIT statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This can never work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;and %substr(&amp;amp;source_table., &amp;amp;i, 1) ne "$/,!@#%^&amp;amp;*" &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You compare a single character with a string; on top of that, you make the mistake of using quotes in macro language. Since the macro language only has the datatype&amp;nbsp;&lt;EM&gt;text&lt;/EM&gt;, quotes are not needed, they actually become part of the text.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It will be easier for you to do the check in a DATA _NULL_ step instead of a macro.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;These are just&amp;nbsp;&lt;EM&gt;some&lt;/EM&gt; observations I've made in your code, there's more. Get your code to work, step-by-step, and always take a look at the results before proceeding to the next step.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 07:08:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897546#M354682</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-06T07:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897553#M354688</link>
      <description>can you suggest me how to check for list of variables in sas code?</description>
      <pubDate>Fri, 06 Oct 2023 08:38:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897553#M354688</guid>
      <dc:creator>varshabansal</dc:creator>
      <dc:date>2023-10-06T08:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897569#M354692</link>
      <description>&lt;P&gt;In PROC SQL, query DICTIONARY.COLUMNS. In a DATA step, use SASHELP.VCOLUMN.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 10:52:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897569#M354692</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-10-06T10:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897574#M354694</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410614"&gt;@varshabansal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="I have this type of excel" style="width: 827px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88687i23502C5E2D12DD35/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="I have this type of excel" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;I have this type of excel&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;So you have the information in DATA already?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why are you writing MACRO code to check the data?&lt;/P&gt;
&lt;P&gt;Write SAS code instead.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 12:54:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897574#M354694</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-06T12:54:39Z</dc:date>
    </item>
    <item>
      <title>Re: Validate multipe tablename and Error handling using sas macro</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897575#M354695</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/410614"&gt;@varshabansal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/12447"&gt;@Patrick&lt;/a&gt; memname should only contain alphabets and underscore not any number but here script allows for numbers also.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Why?&amp;nbsp; What type of system are these datasets part of that do not allow digits in dataset names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For such a simple list of characters &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/fedsqlref/n1seyho5bsm4tpn1iqdzu4gqzfju.htm" target="_self"&gt;VERIFY()&lt;/A&gt; is a good tool.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Oct 2023 12:58:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Validate-multipe-tablename-and-Error-handling-using-sas-macro/m-p/897575#M354695</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-10-06T12:58:05Z</dc:date>
    </item>
  </channel>
</rss>

