SAS Enterprise Guide

Desktop productivity for business analysts and programmers
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 ;
The Boston Area SAS Users Group is hosting free webinars!
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.

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 ;
The Boston Area SAS Users Group is hosting free webinars!
Next up: SAS Trivia Quiz hosted by SAS on Wednesday May 21.
Register now at https://www.basug.org/events.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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