DATA Step, Macro, Functions and more

Accessing Z/OS Datasets from SAS Program

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 6
Accepted Solution

Accessing Z/OS Datasets from SAS Program

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.




Accepted Solutions
Solution
‎04-08-2015 02:31 AM
Contributor
Posts: 37

Re: Accessing Z/OS Datasets from SAS Program

If you need to refer a permanent dataset  created sometime back , you should use the libname statement to point the the dataset librarary and then you can access the dataset by two level name.

Eg:

If my dataset library is "BAS0000.XXX.YY.DATA" and the Dataset name is HAVE.

libname Mydata 'BAS0000.XXX.YY.DATA';

Data

WANT

;

Set

Mydata.HAVE

;

Run;

If you want to refer a Dataset created in the same SAS session  but you have to derive the Dataset name dynamically , you can do something like

DATA

WANT

;

SET

HLQ.SLQ.TLQ.A&YYMMDD

;

RUN;


FILENAME should be used only when we had to access the OS files like reading or writing to a file.


Thanks

Karthik

View solution in original post


All Replies
Super User
Posts: 3,102

Re: Accessing Z/OS Datasets from SAS Program

If it is working fine referencing the DDNAME on the SET statement why are you trying to allocate it a second time in SAS? In any case to allocate a SAS data library in SAS you need a LIBNAME statement not a FILENAME statement.

Solution
‎04-08-2015 02:31 AM
Contributor
Posts: 37

Re: Accessing Z/OS Datasets from SAS Program

If you need to refer a permanent dataset  created sometime back , you should use the libname statement to point the the dataset librarary and then you can access the dataset by two level name.

Eg:

If my dataset library is "BAS0000.XXX.YY.DATA" and the Dataset name is HAVE.

libname Mydata 'BAS0000.XXX.YY.DATA';

Data

WANT

;

Set

Mydata.HAVE

;

Run;

If you want to refer a Dataset created in the same SAS session  but you have to derive the Dataset name dynamically , you can do something like

DATA

WANT

;

SET

HLQ.SLQ.TLQ.A&YYMMDD

;

RUN;


FILENAME should be used only when we had to access the OS files like reading or writing to a file.


Thanks

Karthik

Occasional Contributor
Posts: 6

Re: Accessing Z/OS Datasets from SAS Program

Tq very much Karthik .. Your suggestion worked out for me.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 236 views
  • 0 likes
  • 3 in conversation