Date: Wed, 15 Feb 2006 10:19:40 -0500
Reply-To: Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Peter Crawford <peter.crawford@BLUEYONDER.CO.UK>
Subject: Re: To check whether dataset exist or not in JCL
Is this a dataset <name> in JCL, like
//DSREF DD DSN=<name>,DISP=SHR
or does your JCL refer to something other than a mainframe ?
If you seek conditional logic in JCL, there will be more
help on a JCL-focussed newsgroup than on SAS-L
If JCL is not so important, then in a SAS program, you can use
functions like ( for an external file)
rc = fileexist( 'external.file.name' );
or for a sas library member
rc = exist( sas.membername );
and decide what to do, based on the value returned in RC
or in open code without creating a macro
if a file like external.file.name is renamed by op.sys
%let a1 = x rename external.file.name external.file.name&sysindex ;
%let a0 = ;
&a%sysfunc( fileexist( 'external.file.name' ), z1 ) ;
Something similar can de done for sas data sets like
%let a1 = change membername = membername&sysindex ;
%let a0 = ;
proc datasets nolist library= <whereever> memtype = data ;
&a%sysfunc( exist( membername ), z1 ) ;
If it exists, table membername will be renamed with a numeric suffix
If you want to stop if the name does not exist, why start SAS anyway ?
We can go on guessing what you think you need, but sas-L will
be more helpful if you indicate a little more about what it is
that you really need, and why.
On Tue, 14 Feb 2006 23:26:17 -0800, chethan.gurumurthy@GMAIL.COM wrote:
>Hi JCL Friends,
>It would be a great help if u could solve my problem.
>Following is the problem i do have....
>Before reading or creating any dataset in the program i want to check
>whether the particular dataset exist or not.IS there any function to
>check whether the dataset exist or not.
>The following is the stuff i want to do.
>If the dataset exist then rename dataset X to y,and continue with the
>If the dataset doesn't exist then write the dataset doesn't
>exist...then comeout of the program.
>Thanks a lot well in advance.