LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 1998, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 12 May 1998 11:58:10 -0400
Reply-To:     MICHAEL.RAITHEL@RAITHM49.CUSTOMS.SPRINT.COM
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         "Michael A. Raithel" <MICHAEL.RAITHEL@RAITHM49.CUSTOMS.SPRINT.COM>
Subject:      (MVS): Generating Input File List -- MVS

Michael Stuart posted the following interesting question:

>Does anyone have some sample code that can generate a list >of MVS datasets based on a filename pattern (such as >BX41RH.X041979.XLE023.*.W1998*) -- and pass them all to an >infile statement on a datastep? Or if that's too >complicated, at least create a SAS dataset with one >observation including the file name for every MVS file >that meets the filename pattern? > >I'm running MVS, v6.09, TS455. Thanks in advance folks. >

Michael, no, it is not too complicated! I would attack this problem by using PROC IDCAMS. I would do the following general steps to get the desired output:

1. Execute PROC IDCAMS to do a LISTCAT of the following form: listc lvl('BX41RH.X041979.XLE023')

The above will produce a flat file listing of all OS data sets that begin with BX41RH.X041979.XLE023.

2. Use base SAS, via a DATA step, to "eat" the flat file from above and only create obs that match your pattern:

BX41RH.X041979.XLE023.*.W1998*

Now, you have all of the OS data set names that match the above pattern, and you can get on with it!

Here is an _UNTESTED_ idea of what the code might look like:

BEGIN EXAMPLE: -------------

//******************************************************** //* EXECUTE 'PROC IDCAMS' (IDCAMS) UNDER SAS. * //******************************************************** //STEP01 EXEC SAS,OPTIONS='SYSIN=SASINPUT' //SYSPRINT DD DSN=&&TEMPDSN, // DISP=(,CATLG,DELETE), // SPACE=(CYL,(1,1)),UNIT=SYSDA, // DCB=(RECFM=FBA,LRECL=133,BLKSIZE=27930) //SASINPUT DD *

/*********************************************/ /* ALLOCATE TEMP SYSIN DATA SET. */ /*********************************************/ FILENAME SYSIN '&SYSIN' SPACE=(CYL,(1,1)) UNIT=SYSDA RECFM=FB LRECL=80 BLKSIZE=27920;

/*********************************************/ /* PUT IDCAMS STATEMENT IN THE SYSIN DATA SET*/ /*********************************************/ DATA _NULL_; FILE SYSIN;

PUT " LISTCAT LVL(BX41RH.X041979.XLE023)";

RUN;

/*********************************************/ /* EXECUTE IDCAMS AS A SAS PROC. OUTPUT GOES*/ /* TO THE SYSPRINT DATA SET. */ /*********************************************/ PROC IDCAMS; RUN;

/**********************************************/ /* PARSE THE SYSPRINT DATA SET TO GET THE */ /* SPECIFIC DATA SET NAMES FITTING THE PATTERN*/ /**********************************************/

DATA DSNAME(KEEP=DSNAME); INFILE SYSPRINT;

LENGTH DSNAME $44.;

INPUT @1 BIGLINE $133.;

IF BIGLINE =: '0NONVSAM' THEN DO; DSNAME = SCAN(BIGLINE,3,' ');

X = INDEX(SUBSTRING(DSNAME,23,44),'.'); IF SUBSTR(DSNAME,X,6) = '.W1998' THEN OUTPUT; ELSE DELETE;

END;

ELSE DELETE;

RUN;

/*********************************************/ /* PROCESS THE CAPTURED GDGNAMES... */ /*********************************************/

... more SAS code to process the individual DSN's ...

RUN;

Let's first consider the JCL in the example above. Since both IDCAMS and the SAS System use the SYSIN DD name, it is necessary to reassign the SAS System's SYSIN DD name. This is done through OPTIONS='SYSIN=SASINPUT' on the EXEC statement. You will see that, further down, all of the SAS code follows the SASINPUT DD statement.

Also in the JCL, a temporary SYSPRINT data set is created to capture the output of the IDCAMS command. After that output is captured in this temporary data set, we will process it with SAS character handling functions.

In the SAS code, we begin by creating a SYSIN file for IDCAMS. This SYSIN file must contain valid IDCAMS commands for 'PROC IDCAMS' to execute. We populate the SYSIN file in the DATA _NULL_ step with an IDCAMS LISTCAT command. Everything within the double quotes (including the leading blank) will be inserted into the SYSIN file. It is in the PUT statement that you will put the base nodes of your DSN's. In the example, the base nodes are: BX41RH.X041979.XLE023.

Now, IDCAMS is executed from within SAS via 'PROC IDCAMS'. IDCAMS processes the IDCAMS statements within the SYSIN file and writes output messages to the SYSPRINT file. We have directed IDCAMS to list every cataloged data set that begins with: BX41RH.X041979.XLE023.

The final SAS DATA step parses the SYSPRINT data set, capturing the individual DSNAMES. The INDEXC SAS function is used to determine if the fifth node of the DSNAME begins with: ".W1998" If so, an observation is created; if not, the record is discarded. Those DSNAMES that match the specified pattern are written to variable DSNAME and populate a data set called DSNAME. At this point, you have all of the DSNAMES that you require. You can go on to do... whatever you have to do with them.

END EXAMPLE; -----------

Michael, I'm sure that you can bend, shape, and mold the above example to your liking and pursue your goal. Good luck in your quest to seek out and process data sets in that Mount Olympus of all operating systems: OS/390 (MVS)!

I hope that this suggestion proves helpful now, and in the future!

Of course, all of these opinions and insights are my own, and do not reflect those of my organization or my associates.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Michael A. Raithel "The man who wrote the book on performance" E-mail: maraithel@mcimail.com Author: Tuning SAS Applications in the MVS Environment +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ What is written with little effort is, in general, read with little pleasure. -- Samuel Johnson +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


Back to: Top of message | Previous page | Main SAS-L page