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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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