BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mariko5797
Pyrite | Level 9

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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


View solution in original post

2 REPLIES 2
Reeza
Super User

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.


 

Tom
Super User Tom
Super User

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


SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 699 views
  • 1 like
  • 3 in conversation