- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc compare base=premig.ae compare=postmig.ae out=test novalues ;
run;
Hi,
Please find the attached sample code and output image.
I am trying to run a comparison between folders and all I am looking for is a simple output like this one.
I don't need all other summaries it prints, I just need a table as attached. How can I achieve this?
I have tried all the options but they seem to produce a lot of other comparisons.
Please advise.
Thank you
- Tags:
- kurtBremser
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What do you mean by "run a comparison between folders"?
Proc compare compares data sets, not folders.
This output dataset, named Myoutputset below, will have that information. However it will have all of the output, not just that circled. That is due to the nature of ODS Output, it creates tables of the results, and in this case includes the headings and more than you want.
ods output comparedatasets = myoutputset;
proc compare base=premig.ae compare=postmig.ae out=test novalues ;
run;
I would suggest a different approach and query the metadata that SAS keeps.
proc sql; create table somename as select * from dictionary.tables where libname in ('PREMIG' 'POSTMIG') and memname in ('AE') ; QUIT;
This will get just about anything you want to know about the properties of the two data sets. You can list the specific variables you want such as Libname, Memname, CRdate, Moddate, Nvar, Nobs if that is all you are interested in.
This approach would let you get the summary data for many more data sets. If you have catalogs or such that have the same name as the data sets you would would to add "and memtype='DATA'. If you want the details for all of the sets in the libraries then skip the "and memname in ()" part of the code.
DICTIONARY.TABLES and others are special views of the data and have a the special location Dictionary that is NOT a library name. Proc SQL uses that special name to reference the contents. The values of Libname and Memname must be in upper case as that is how they are stored. You can look at the library SASHELP for views whose names start with V (mostly) for a data step approach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
A PROC CONTENTS of each dataset should provide that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I don't think, the contents procedure would compare two datasets and print out a report as I wanted.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
What do you mean by "run a comparison between folders"?
Proc compare compares data sets, not folders.
This output dataset, named Myoutputset below, will have that information. However it will have all of the output, not just that circled. That is due to the nature of ODS Output, it creates tables of the results, and in this case includes the headings and more than you want.
ods output comparedatasets = myoutputset;
proc compare base=premig.ae compare=postmig.ae out=test novalues ;
run;
I would suggest a different approach and query the metadata that SAS keeps.
proc sql; create table somename as select * from dictionary.tables where libname in ('PREMIG' 'POSTMIG') and memname in ('AE') ; QUIT;
This will get just about anything you want to know about the properties of the two data sets. You can list the specific variables you want such as Libname, Memname, CRdate, Moddate, Nvar, Nobs if that is all you are interested in.
This approach would let you get the summary data for many more data sets. If you have catalogs or such that have the same name as the data sets you would would to add "and memtype='DATA'. If you want the details for all of the sets in the libraries then skip the "and memname in ()" part of the code.
DICTIONARY.TABLES and others are special views of the data and have a the special location Dictionary that is NOT a library name. Proc SQL uses that special name to reference the contents. The values of Libname and Memname must be in upper case as that is how they are stored. You can look at the library SASHELP for views whose names start with V (mostly) for a data step approach.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I initially taught, the solution to my problem would be complex. After looking at the dictionary tables, a solution was right in front.
I was not looking for a detailed record-level comparison. The approach with dictionary tables simplified the process.
Thank you for reminding me about the dictionary tables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
See if you let ODS help you.
Turn on ODS trace. Run your PROC COMPARE. See what output is the one that writes that dataset summary table and only select that one to print. Do you know how to use ODS trace, ODS select , ODS exclude, etc?
Do you know how to use ODS OUTPUT? If so send that output to a dataset and remove the lines you don't want.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
PROC COMPARE does not work with folders. The word "folder" is used in SAS for parts of the hierarchical structure of SAS metadata, or as a synonym for directories in the operating system's filesystem.
PROC COMPARE compares datasets, which are (on the physical side) files within a directory (which you can call a "folder") for which a LIBNAME has been defined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc compare base=have1 compare=have2 ;run;