I have two datasets that should be the same. Using PROC COMPARE, I saw that values of variables available in both datasets are the same. However, one dataset has more variables than the other. Is there a way to check which variables (i.e. columns) are missing? Since there are 100+ variables, I would rather not visually check this.
Use the LISTVAR , or LISTALL, option.
proc compare data=sashelp.class(drop=age) compare=sashelp.class(drop=sex)
listvar
;
run;
Listing of Variables in SASHELP.CLASS but not in SASHELP.CLASS Variable Type Length Sex Char 1 Listing of Variables in SASHELP.CLASS but not in SASHELP.CLASS Variable Type Length Age Num 8
PROC COMPARE includes that in the output. There's a section titled:
Listing of Variables in Dataset1 and not in Dataset2
See second image in this example.
https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/proc/p1k00d45g03uv8n1bfx3d20breg6.htm
Try adding the PRINTALL option to PROC COMPARE if it's not appearing for you.
@mariko5797 wrote:
I have two datasets that should be the same. Using PROC COMPARE, I saw that values of variables available in both datasets are the same. However, one dataset has more variables than the other. Is there a way to check which variables (i.e. columns) are missing? Since there are 100+ variables, I would rather not visually check this.
Use the LISTVAR , or LISTALL, option.
proc compare data=sashelp.class(drop=age) compare=sashelp.class(drop=sex)
listvar
;
run;
Listing of Variables in SASHELP.CLASS but not in SASHELP.CLASS Variable Type Length Sex Char 1 Listing of Variables in SASHELP.CLASS but not in SASHELP.CLASS Variable Type Length Age Num 8
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.