1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| option symbolgen mprint mlogic;
%macro names(table=);
%let dsid=%sysfunc(open(&table,i));
%do i=1 %to %sysfunc(attrn(&dsid,nvars));
%global varlist;
%let varlist= %sysfunc(varname(&dsid,&i));
%global varlist ;
%global vartype&i;
%global mac_dist_&varlist;
data _null_;
if 0 then set &table;
call symputx ('vartype'||strip(&i), vtype( &varlist ) );
run;
%if &&vartype&i = N %then %do;
%global mac_min_&varlist;
proc sql noprint;
select min( &varlist) into : mac_min_&varlist from &table ;
quit ;
%end;
proc sql noprint;
select count(distinct &varlist) into : mac_dist_&varlist from &table ;
quit ;
%put &&mac_&varlist;
%end;
%let rc=close(&dsid);
%mend names;
%names(table=sashelp.class);
proc sql;
create table macro as select value, scan(name,3,'_') as name, scan(name,2,'_') as stat from sashelp.vmacro
where substr(name,1,8)='MAC_DIST' or substr(name,1,7)='MAC_MIN'
order by name, stat;
quit;
proc transpose data =macro out=macro1(drop =_NAME_ _LABEL_) ; by name; id stat;var value; run;
proc sql;
create table discription as select t.*, t1.dist, t1.min
from
(select * from sashelp.vcolumn
where libname ='SASHELP' and memname ='CLASS') as t
inner join
(select name, dist, min from macro1) as t1
on upcase(t.name)=upcase(t1.name)
;
quit; |
Partager