Sample 24575: How to combine all the source entries in a catalog into one data set
The CATALOG procedure is used to list the entries of the catalog. The CATALOG access method with the FILEVAR= option is used to loop through all the source entries in the catalog to create one data set.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/********************************************************************/
/* Using PROC CATALOG, create an output data set containing */
/* information on the contents of a SAS Catalog such as */
/* SASUSER.PROFILE. */
/* */
/* Use this output data set to create the four-part name needed to */
/* access the catalog entries with an INFILE statement. The INFILE */
/* statement uses the CATALOG access method with the FILEVAR= option */
/* to read all the source entries in the catalog and create one data */
/* set. */
/********************************************************************/
/* Point PROC CATALOG to the catalog of interest */
proc catalog catalog=sasuser.profile;
contents out= catlist;
run;
quit;
/* Keep only the SOURCE files. You can do a PROC PRINT to see the */
/* type of information returned by PROC CATALOG as well. */
data cat_source;
set catlist;
where type='SOURCE';
run;
data code;
set cat_source;
/* Increase LENGTH if needed, to avoid truncation */
length cat $100 fname $50;
cat=trim(libname) || '.' || trim(memname) || '.' || trim(name) ||'.source';
infile dummy catalog filevar=cat end=done filename=fname truncover;
filnam=fname;
do while(not done);
input varname $100.;
output;
end;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Note: No output is illustrated here as the actual results
are dependent upon the available source code in your SASUSER.PROFILE.
SOURCE entries in a catalog contain DATA step or PROC code. Multiple source entries can be combined into one data set using this sample code.
Type: | Sample |
Topic: | SAS Reference ==> DATA Step Common Programming Tasks ==> Reading and Writing External Data
|
Date Modified: | 2005-12-08 11:34:06 |
Date Created: | 2004-09-30 14:08:55 |
Operating System and Release Information
SAS System | Base SAS | All | n/a | n/a |