In reply to Leonid Batkhan.

Hi Leonid,

I modified it slightly in that way that everybody gets 4 macro vars which can be used afterwards with only one call %GetDSinfo(SASHELP.CARS);

Really nice :)

%macro GetDSinfo(dset);
/* dset - data set name */
%local dsid result infocaps i;
%let infocaps = ALL;
%let dsid = %sysfunc(open(&dset));
%global _NOBS _NVARS _VARLIST _VARLISTC;

%if &dsid %then
%do;
%if &infocaps=ALL %then %let _NOBS = %sysfunc(attrn(&dsid,nlobs));
%if &infocaps=ALL %then %let _NVARS = %sysfunc(attrn(&dsid,nvars));
%if &infocaps=ALL %then
%do i=1 %to %sysfunc(attrn(&dsid,nvars));
%let result = &result %sysfunc(varname(&dsid,&i));
%let _VARLIST=&result;
%end;
%if &infocaps=ALL %then
%do i=1 %to %sysfunc(attrn(&dsid,nvars));
%if &i eq 1 %then %let result = %sysfunc(varname(&dsid,&i));
%else %let result = &result,%sysfunc(varname(&dsid,&i));
%let _VARLISTC=&result;
%end;
%let dsid = %sysfunc(close(&dsid));
%end;
%else %put %sysfunc(sysmsg());

%mend GetDSinfo;

%GetDSinfo(SASHELP.CARS);

%put _NOBS: &_NOBS;
%put _NVARS: &_NVARS;
%put _VARLIST: &_VARLIST;
%put _VARLISTC: &_VARLISTC;