here is an scl solution you'll need to modify your macro parameters to use this but otherwise, it can be used to call any macro for every variable in a data set. options mprint source2;
*include 'freqhilo.sas';
%let libname = sashelp;
%let memname = class;
%let macro_name = mymacro;
%let macro_name = echo;
%macro echo(libname=,memname=,name=,type=,length=,varnum=);
%put _local_;
%mend;
*echo(libname=1,memname=2,name=3,type=4,length=5,varnum=6);
*endsas;
%let _dsid = %sysfunc(open (&libname..&memname,i));
%let _n_obs = %sysfunc(attrn(&_dsid,nobs));
%let _n_vars = %sysfunc(attrn(&_dsid,nvar));
%let _rc = %sysfunc(close(&_dsid));
%put echo &=_n_obs &=_n_vars;
DATA _null_;
attrib name length = $32
type length = $1
length length = 8
statement length = $128;
_dsid = open("&libname..&memname");
do varnum = 1 to &_n_vars;
name = varname (_dsid,varnum) ;
type = lowcase(vartype (_dsid,varnum));
length = varlength(_dsid,varnum);
statement = catt
('%',"¯o_name"
,'(name=' ,name
,',type=' ,type
,',length=',length
,',varnum=',varnum
,",libname=&libname,memname=&memname)"
);
put statement;
call execute(catt('%nrstr(',statement,')'));
end;
_rc = close(_dsid);
run; Ron Fehd this program is based on my SESUG.2017 paper Advanced Programming Concepts Cardinality Ratios and Types code in the paper will be available after Nov 4. http://www.sascommunity.org/wiki/Cardinality_Ratios_and_Types
... View more