BookmarkSubscribeRSS Feed
Sreeni
Calcite | Level 5

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.


6 REPLIES 6
Jagadishkatam
Amethyst | Level 16

Please try


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

%PUT &FNAME;

Thanks,
Jag
Reeza
Super User

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

DATA WANT;

SET &FNAME;

RUN;

Sreeni
Calcite | Level 5

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.

Sreeni
Calcite | Level 5

I was able to get thru using LIBNAME.

Tx for all your assistance.

jakarman
Barite | Level 11

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 --<-----

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2056 views
  • 6 likes
  • 5 in conversation