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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.