|
data test;
input x1 $ x2 $ x3 $ x4 $ x5 $ x6 $ ;
cards;
c1 c3 c5 c3 c1 c2
c2 c8 c9 c2 c9 c8
;
run;
data test ;
set test end=eof ;
if eof then call symput("TotalRecords", _n_) ;
run;
%put &totalRecords ;
proc transpose data = test out=one ;
var x1 - x6 ;
run;
%macro getcount ;
proc sql ;
create table two as
select %do i=1 %to &totalRecords ;
col&i,
%end ;
_NAME_
from one
union
select %do i=1 %to &totalRecords ;
strip(put(count(distinct col&i.), best8.)) as col&i ,
%end ;
'Num' as _NAME_
from one ;
quit ;
%mend getcount ;
%getcount
proc transpose data=two out=temp(drop=_name_) ;
id _NAME_ ;
var COL: ;
run;
data temp (drop=num);
set temp ;
num_count=input(num,best8.) ;
run;
|