Hi All, I want to mask the variables values with 'XXXX' in all datasets so I created a macro with masking variables. 'names' data set has all variables (name,title,name_s house_name house_number) but 'test'data set has only two variables .when I use this test macro for test table it is creating dummy varables and also remaining datasets doesn't have all the variables. I used below code to check the varable existence but I am stuck here .if variables exits then mask else don't mask .(I need this kind of approach). %macro VarExist(ds, var);
%local rc dsid result;
%let dsid = %sysfunc(open(&ds));
%if %sysfunc(varnum(&dsid, &var)) > 0 %then %do;
%let result = 1;
%put NOTE: Var &var exists in &ds;
%end;
%else %do;
%let result = 0;
%put NOTE: Var &var not exists in &ds;
%end;
%let rc = %sysfunc(close(&dsid));
&result
%mend VarExist;
%put %VarExist(names, name);
%macro test;
name=tranwrd(name, trim(name), "xxxxx");
title=tranwrd(title, trim(title), "xxxxx");
name_s=tranwrd(name_s, trim(name_s), "xxxxx");
house_name=tranwrd(house_name, trim(house_name), "xxxxx");
house_number=tranwrd(house_number, trim(house_number), "xxxxx");
%mend;
data a;
set names;
%test;
/*ss=cat(title,name);*/
run;
data b;
set test;
%test;
run; sorry my question is not that clear. Tahnks, S.
... View more