BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
alepage
Barite | Level 11

Hello,

 

I need to copy some datsets from path1 to path1/backup.  Then  I need to copy some datasets from path2 to path1.

But before doing that, I would like to compare the variables (only the variables not their values, and variables atttributes) in each dataset.

 

I have tried 

 

proc compare base=FTEDATA.Agent  compare=FTESGOT. Agent novalues;

run;

 

But It  still see values comparison.

 

what's the best options ?

1 ACCEPTED SOLUTION

Accepted Solutions
Quentin
Super User

You can set obs=0 for both datasets, i.e.:

proc compare base=FTEDATA.Agent (obs=0)  compare=FTESGOT.Agent (obs=0) listvars;
run;

Compare will throw a warning, but it still compares the metadata.

 

Another option is to use PROC CONTENTS to output variable metadata as data, and then you can use PROC COMPARE on the datasets. e.g. 

 

data have ;
  set sashelp.class (drop=weight);
run ;

proc contents data=sashelp.class out=class_vars (keep=name type length label /* etc */ );
run ;

proc contents data=have out=have_vars (keep=name type length label /* etc */ ) ;
run ;

proc compare base=class_vars compare=have_vars error listobs;
 id name ;
run ;

View solution in original post

1 REPLY 1
Quentin
Super User

You can set obs=0 for both datasets, i.e.:

proc compare base=FTEDATA.Agent (obs=0)  compare=FTESGOT.Agent (obs=0) listvars;
run;

Compare will throw a warning, but it still compares the metadata.

 

Another option is to use PROC CONTENTS to output variable metadata as data, and then you can use PROC COMPARE on the datasets. e.g. 

 

data have ;
  set sashelp.class (drop=weight);
run ;

proc contents data=sashelp.class out=class_vars (keep=name type length label /* etc */ );
run ;

proc contents data=have out=have_vars (keep=name type length label /* etc */ ) ;
run ;

proc compare base=class_vars compare=have_vars error listobs;
 id name ;
run ;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 1 reply
  • 856 views
  • 1 like
  • 2 in conversation