Macro SAS folder content compare

Reply
Occasional Contributor
Posts: 11

Macro SAS folder content compare

I found this macro to compare two sas folders but the macro is not compiling, please help. thanks.

The macro is attached.

Attachment
Super User
Super User
Posts: 6,843

Re: Macro SAS folder content compare

What is your definition of COMPARE in this case?

You do not need all of those directory read commands to get a list of SAS datasets, Just make a libref and use PROC CONTENTS or one or more of the dictionary views.

Super Contributor
Posts: 339

Re: Macro SAS folder content compare

This is a very, very simple code which checks if the files in to libraries are the same and might help. It creates a macro variable that tells if the contents are the same or not.


Proc Datasets Library=Results NoList;  /* Lib1=results --> change */
  Contents Data=_ALL_ Out=Work.List_Results NoPrint;
Run;

Proc Datasets Library=Work Memtype=Data NoList;
  Modify List_Results;
    Attrib _ALL_ Label=' ';
Attrib _ALL_ Format=;
Run;

Proc Sort Data=List_Results Nodupkey;
  By MEMNAME;
Run;

Proc Datasets Library=Param NoList;  /* Lib2=Param --> change */
  Contents Data=_ALL_ Out=Work.List_Param NoPrint;
Run;

Proc Datasets Library=Work Memtype=Data NoList;
  Modify List_Param;
    Attrib _ALL_ Label=' ';
Attrib _ALL_ Format=;
Run;

Proc Sort Data=List_Results Nodupkey;
  By MEMNAME;
Run;

Data Different;
  Merge List_Results (in=inR) List_Param (in=inP);
  By MEMNAME;
  If not (inR & inP);
Run;

Data _NULL_;
  FileN=Open("Different");
  Equal_Lib=Attrn(FileN,"ANY");
  Call Symput ("Equal_Lib",Equal_Lib);
Run;

%Put **&Equal_Lib.**(1 means not equal)**;

Super User
Super User
Posts: 7,710

Re: Macro SAS folder content compare

Hi,

data _null_;

     set sashelp.vtables (where=(libname="xxx" and memname="yyy"));

     call execute('proc compare base=xxx.'||strip(memname)||' comp=other.'||strip(memname)||' out='||strip(memname)||';

                              run;');

run;

Note maybe typos as in meeting all day.

Ask a Question
Discussion stats
  • 3 replies
  • 279 views
  • 0 likes
  • 4 in conversation