-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuni()
More file actions
16 lines (16 loc) · 769 Bytes
/
uni()
File metadata and controls
16 lines (16 loc) · 769 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
%macro uni(data, var);
proc sql noprint;
select count(distinct &var) into :unique trimmed from &data;
select count(*) into :noobs trimmed from &data;
select sum(missing(&var)) into :miss trimmed from &data;
quit;
%let percent = %sysevalf(&miss/&noobs*100,floor);
%put #########################################################;
%if %sysevalf(&noobs-&unique) = 0 %then %do; %put WARNING- All observations are unique!; %end;
%else %put ERROR- All observations are NOT unique;
%put #########################################################;
%put ##### &noobs number of observations in &data;
%put ##### &unique unique values of &var;
%put ##### &miss missing values of &var (&percent.% of all obs);
%put #########################################################;
%mend;