Skip to content

Instantly share code, notes, and snippets.

@statgeek
Created July 26, 2018 18:12
Show Gist options
  • Select an option

  • Save statgeek/95080ffddc5217af80248fd078dfbfeb to your computer and use it in GitHub Desktop.

Select an option

Save statgeek/95080ffddc5217af80248fd078dfbfeb to your computer and use it in GitHub Desktop.
SAS - which variables are missing from the data set in comparison to another data set
*create example data;
data class;
set sashelp.class;
run;
data class2;
set sashelp.class;
drop age sex;
run;
*set macro variables;
%let lib_master=work;
%let master=Class2;
%let lib_sub=work;
%let sub=Class;
%let dlm=" ";
*create a variable list of missing variables;
proc sql noprint;
select name into :drop_list separated &dlm.
from sashelp.vcolumn
where upper(libname)=upper("&lib_sub.")
and upper(memname) = upper("&sub")
and name not in (select name
from sashelp.vcolumn
where upper(libname)=upper("&lib_master.")
and upper(memname) = upper("&master"));
quit;
*show results;
%put &drop_list;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment