DATA Step, Macro, Functions and more

Referring Files from SAS

Reply
Occasional Contributor
Posts: 6

Referring Files from SAS

Hi,

I need to access a mainframe dataset (SAS file) from SAS Program.

I cannot pass the Dataset name from JCL as the file name is not fixed.

Eg ... File Name is  :  HLQ.SLQ.TLQ.A&YYMMDD.

In SAS program I can derive YYMMDD and can be able to make up the File name.

I need assistance for how to refer the file name and access it from SAS program.


I am trying the following :

Getting current date as : 20150407 in SAS program.


%LET FNAME = HLQ.SLQ.TLQ.A&YYMMDD;

%PUT &FNAME;


FILENAME INFIL "&FNAME"

                              DISP=SHR;


DATA WANT;

SET INFIL;

RUN;


The above is giving error. File name is resolving properly (HLQ.SLQ.TLQ.A150704) but its giving me error stating Error in the FILENAME statement.

File WORK.INFIL.DATA does not exist.


Can some one please assist how to access the Dataset (File) from SAS Program.


Where as If I pass the the dataset name as HLQ.SLQ.TLQ.A150704 from JCL then its working fine (just putting the DD Name mentioned in JCL at SET is working fine).


Regards,

Sree.


Trusted Advisor
Posts: 1,128

Re: Referring Files from SAS

Please try


%LET FNAME = HLQ.SLQ.TLQ.A%cmpres(&YYMMDD);

%PUT &FNAME;

Thanks,
Jag
Super User
Posts: 17,750

Re: Referring Files from SAS

If the dataset is a SAS dataset you would use the FNAME directly:

DATA WANT;

SET &FNAME;

RUN;

Occasional Contributor
Posts: 6

Re: Referring Files from SAS

Thank you Jagadesh & Reeza.

I am able to get the variables resolve now but its giving me error like "Invalid Dataset Name".

Let me give few more details about the Dataset structure.

We have SAS File resides inside MVS file.

MVS File name = HLQ.SLQ.TLQ.A%cmpres(&YYMMDD).

SAS File Name = AB_1XYZ%cmpres(&YYMMDD).

If I pass the hard coded MVS Dataset Name from JCL and refer the same at SET as follows its working fine.

SET JCLDDNAME.SASFILENAME

But If I dont pass from JCL and derive the file name in SAS Program as follows, the file name is resolving properly and showing the variables and the file names exactly as expected.

%LET MFILE1=HLQ.SLQ.TLQ.A%cmpres(&YYMMDD).

%PUT &MFILE1;

SFILE1=AB_1XYZ%cmpres(&YYMMDD).

%PUT &SFILE1;

But after SET statement its giving me error as "There is not a default input data set (_Last_ is _Null_).

Error 211-185: Invalid dataset name.

I am giving SET as follows:

DATA WANT;

SET &MFILE1..&SFILE1;

Can you please assist for this. Thank you very much for your support.

Super User
Posts: 6,928

Re: Referring Files from SAS

SFILE1=AB_1XYZ%cmpres(&YYMMDD).


You're missing the %let here, so the macro variable is never defined.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 6

Re: Referring Files from SAS

I was able to get thru using LIBNAME.

Tx for all your assistance.

Valued Guide
Posts: 3,208

Re: Referring Files from SAS

Sreeni ok libname (sas-dataset tables) and files (raw text files) filenames are different type data. You solved that.

As you are working on a mainframe there are a lot small differences with all approaches.

- Libnames and filenames cannot share the same name as with Windows/Unix. You have seen the JCL and an IO-definition cannot be duplicated.

- Going into production with a Scheduler (eg OPC) the requirement will be to have that dataset in JCL. OPS is supporting supplying scheduled dynamic dates.

  By that the scheduler is able to plan and avoiding locking situations.

  If you are for that than you can do something similar in the develop environment.

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 6 replies
  • 734 views
  • 6 likes
  • 5 in conversation