BookmarkSubscribeRSS Feed
eagles_dare13
Obsidian | Level 7

If I have 10 sas datasets in folder A and 10 sas datasets in folder B, can I compare the two folders, matching the datasets by their name, or do i need to write 10 different proc compare statements, one for each data set?

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Have a look at the macro documentation.   Also you could use a datastep and call execute.  There are many examples on here on either style.

%macro do_compare(file=);

     proc compare base=&file. comp=file out=&comp_file.;

     run;

%mend do_compare;

%do_compare(file=filea);

%do_compare(file=fileb);

ballardw
Super User

If there is something specific you are trying to determine it might be time to ask for help with the specific desired comparisons. Since Proc Compare kind of expects sets to be sorted in the same order to get many of the more interesting results ...

Saidurga1
Calcite | Level 5

libname new "/dmenv/dmwork/gsk2118436/brf113928/test/raw/FROM_FSP/Transfer_20190916/BRF113928_ToNovartis_20190916/new";

libname old "/dmenv/dmwork/gsk2118436/brf113928/test/raw/FROM_FSP/Transfer_20190910/BRF113928_ToNovartis_20190910/old";

 

proc sql;

select distinct memname into:macvar separated by ' '

from sashelp.vstable

where upcase(libname)="NEW" ;

quit;

%put &macvar;

 

%macro test;

%local i;

%do i= 1 %to &sqlobs;

%let dst=%scan(&macvar,&i,' ');

Proc Compare Base = new.&dst Compare = old.&dst/*Outbase OutComp Outdiff Outnoequal*/listall

Out = Dm_Diff_comp ;

Run;

%end;

%mend;

%put &dst ;

%test;

 

 

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 6795 views
  • 0 likes
  • 4 in conversation