Hello,
I wrote the following code:
%macro getTables(saplib=SAPBW,saslib=SAP_TEXT);
options validmemname=extend validvarname=any;
data texttbls;
set sashelp.vtable;
where libname = "&saplib" and (memname =: "/BI0/T" or memname =: "/BIC/T");
run;
data _null_;
set texttbls;
call symputx('texttbls',_n_);
call symputx(catt('saptexttbl',_n_),memname);
call symputx(catt('sastexttbl',_n_),translate(memname,"_","/"));
run;
%do i = 1 %to &texttbls;
data &saslib.."&&sastexttbl&i"n;
set &saplib.."&&saptexttbl&i"n;
run;
%end;
%mend;
%getTables();
I want the loop not to try to read from the SAPBW library two tables.
Table names: _BI0_TRELOCAT + _BI0_TLVANOFT.
What change should be made to the code?
Thank's.
So is the actual requirement that you don't want to run the data step when the name is not changing?
If so add a WHERE statement to the data step or augment the WHERE condition in the SQL query.
data _null_;
set texttbls;
where memname ne translate(memname,"_","/");
Or perhaps just
data _null_;
set texttbls;
where indexc(memname,'/');
Since you have the names of the tables in a data set I would consider using Call Execute instead of creating macro variables.
Then you could test the value of the Memname variable not do the call execute.
Dummy code;
data _null_; set texttbls; if memname not in ("_BIO_TRELOCAT" "_BIO_TLVANOFT") then call execute ("build that data step code here"); run;
@shlomiohana wrote:
Hello,
I wrote the following code:
%macro getTables(saplib=SAPBW,saslib=SAP_TEXT); ... %getTables();
I want the loop not to try to read from the SAPBW library two tables.
Table names: _BI0_TRELOCAT + _BI0_TLVANOFT.
What change should be made to the code?Thank's.
You've set the macro at the top to read from the SAPBW library. If you want to change that library you can try to change the macro call.
%getTables(saplib=newLibraryHERE, saslib=SAP_TEXT);
@shlomiohana wrote:
Hello,
I wrote the following code:
%macro getTables(saplib=SAPBW,saslib=SAP_TEXT); options validmemname=extend validvarname=any; data texttbls; set sashelp.vtable; where libname = "&saplib" and (memname =: "/BI0/T" or memname =: "/BIC/T"); run; data _null_; set texttbls; call symputx('texttbls',_n_); call symputx(catt('saptexttbl',_n_),memname); call symputx(catt('sastexttbl',_n_),translate(memname,"_","/")); run; %do i = 1 %to &texttbls; data &saslib.."&&sastexttbl&i"n; set &saplib.."&&saptexttbl&i"n; run; %end; %mend; %getTables();
I want the loop not to try to read from the SAPBW library two tables.
Table names: _BI0_TRELOCAT + _BI0_TLVANOFT.
What change should be made to the code?Thank's.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.