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 ?
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 ;
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 ;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.