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 ;
BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: 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 ;
BASUG is hosting free webinars Next up: Don Henderson presenting on using hash functions (not hash tables!) to segment data on June 12. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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