Sample 48933: How to use SASĀ® to obtain the creation date for a z/OS data set using the DSCB INFILE statement option
Overview
Users have asked how they can determine the creation date for a z/OS data set. Some possible uses for this information are:
- Direct access storage device (DASD) management. For example, you want to delete a data set older than x days.
- Use in reporting. For example, for a header in a report, you might want the date on which the data was generated.
- Synchronization of multiple data sources used for analysis and reporting. For example, you might want to verify that disparate data sources are current for the processing to be performed.
The sample under the Full Code tab is a SAS macro that uses two keyword arguments.
- DSN= is a required argument. The z/OS data set for which to obtain the create date.
- CRDTVAR= is an optional argument. The macro variable name to create to store the create date in. The default value is CRDT.
Usage Examples
Example 1
/* Make available through autocall services in SAS */
options sasautos=(sasautos,'pds.name.where.dscrdt.stored');
/* Call DSCRDT macro passing in DSN= argument; default macro variable contains result */
%dscrdt(dsn='my.test.data');
/* Display the Create Date value in the SAS log */
%put Create Date is: &crdt;
Example 2
/* Directly %INCLUDE the macro in the SAS program */
%include 'pds.name.where.dscrdt.stored(DSCRDT)';
/* Call DSCRDT macro passing DSN= and CRDTVAR= arguments */
%dscrdt(dsn=my.test.data2,crdtvar=d2crdt);
/* Display the Create Date in the SAS log */
%put Create Date is: &d2crdt;
Additional Documentation
-
SAS® 9.3 Functions and CALL Routines: Reference
-
SAS® 9.3 Macro Language: Reference
-
SAS® 9.3 Companion for z/OS
-
z/OS V1R13.0 DFSMSdfp Advanced Services
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.
The DSCRDT macro first validates that a DSN= argument was passed. Otherwise, it generates an error message. If DSN= was specified, then the macro extracts the creation date from the DSCB using DATA step code and formats it as a DATE9 value. This value is stored in the global macro variable specified in the CRDTVAR parameter passed to the macro.
%macro dscrdt(dsn=,crdtvar=crdt);
%global &&crdtvar;
%if &dsn eq %str() %then
%do;
%put ERROR: You must provide a DSN= value on call to this macro.;
%end;
%else
%do;
data _null_;
length x $ 100;
infile "&dsn" dscb=x;
/* The following converts the creation date in the DSCB to a */
/* valid SAS formatted date. */
/* This is the Y2K compliant version. */
year=input(substr(x,10,1),ib1.)+1900;
dscbcd=put(input(put(year,4.)||put(input(substr(x,11,2),ib2.),
z3.),julian7.),date9.);
call symput("&crdtvar",dscbcd);
run;
%end;
%mend dscrdt;
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.
There are various methods for obtaining a data set creation date with SAS in a z/OS environment. This sample illustrates one method using the DSCB option of the INFILE statement.
| Date Modified: | 2013-03-13 17:09:14 |
| Date Created: | 2013-01-16 09:40:27 |
Operating System and Release Information