Created
July 26, 2018 18:12
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| *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