BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hi,
Please help me in correcting the code. Our workshop has SAS under Z/OS.

I have VSAM file configuration shown below:

Organization: KSDS
KSDS key length: 4
KSDS key location: 0
Average record size: 80
Maximum record size: 80


Here is the sample output from the file:

---- +----1----+----2-
**********************
1234 saikrishna
1235 xxxxxxxxxx

Here is the code I used to access key 1235

DATA FILEIN;
ID='1235';
KEYVAR= ID;
INFILE INFIL VSAM KEY=KEYVAR;
INPUT
@5 NAME $CHAR12.;
;
PROC PRINT DATA=FILEIN;
;

The Mainframe batch job keep on running for ever.. I cancelled the job and added the code IF _N_ > 100 THEN STOP; then I noticed the logic is reading the same record again and again (in the output it has 100 records same).

Could you please suggest me the code to handle this situation?



Thanks,
Sai



PS: Yesterday I posted this topic in SAS Enterprise Guide thread. I do not have access to remove my topic there. I request Admin to remove topic from that thread.
12 REPLIES 12
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Provide the SASLOG output, and add OPTIONS OBS=0; to your SAS program for short-circuit execution.

Also, another possibility to increase diagnostics, add some PUT _ALL_; statements (or PUTLOG in SAS 9) to help determine what is happening with the DATA step.

Also, are you getting CPU time and is there I/O activity -- information available from your JOB OUTPUT and from your batch job monitor (like SDSF)?

Has this particular code worked in the past or is it the first attempt? And are you able to access the same file, say with IDCAMS?

Helplful diagnostics in order to get to the bottom.

Scott Barry
SBBWorks, Inc.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Also, I searched the SAS support website http://support.sas.com/ and found this support tech note that may apply:

Problem Note 30979: Performance degradation might occur in SAS®9 if you process VSAM files on a Remote Library Services (RLS) server

http://support.sas.com/kb/30/979.html


Have your SAS admin investigate the SAS 9 HOTFIX website for the associated maintenance (mind any broken URLs):

ftp://ftp.sas.com/techsup/download/hotfix/e9_sbcs_prod_list.html



Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Thanks so much for responding.. Please see my answer to your queries....

Provide the SASLOG output, and add OPTIONS OBS=0; to your SAS program for short-circuit execution

NOTE: This installation is running Base SAS hot fix bundle 82BX06.

Welcome to the SAS Information Delivery System,

888 888 Release 8.2!
8 8 8 8
8 8 8
8 8 8 This message displays in the SAS log when
8 8 the NEWS option is specified. You can
88 8 8 8 replace it with your own message by editing
8 8 8 8 8 the NEWS file.
8 8 8 8 8
8 888 8 88888



NOTE: The SASUSER library was not specified. SASUSER library will now b
NOTE: All data sets and catalogs in the SASUSER library will be deleted
prevent their deletion.

NOTE: SAS system options specified are:
SORT=4
NOTE: The initialization phase used 0.04 CPU seconds and 5453K.
1 OPTIONS OBS=0;
2 DATA FILEIN;
3 ID='1235';
4 KEYVAR= ID;
5 INFILE INFIL VSAM KEY=KEYVAR;
6 INPUT
7 @5 NAME $CHAR12.;
8 ;

NOTE: The infile INFIL is:
Dsname=BCST.SAI.TEST,
Volume=CGNP6H,Disp=SHR,Unit=3390,Type=INDEXED,
12 The SAS Sys

Spanned=NO,Recordsize=(.,80),Amp=('AMORG'),
Records=2,Keys=(4 0)

NOTE: 0 records were read from the infile INFIL.
NOTE: The data set WORK.FILEIN has 0 observations and 2 variables.
NOTE: The DATA statement used 0.03 CPU seconds and 7233K.

9 PROC PRINT DATA=FILEIN;
10 ;
NOTE: No observations in data set WORK.FILEIN.
NOTE: The PROCEDURE PRINT used 0.01 CPU seconds and 8044K.

NOTE: The SAS session used 0.08 CPU seconds and 8044K.
NOTE: SAS Institute Inc., SAS Campus Drive, Cary, NC USA 27513-2414


Also, another possibility to increase diagnostics, add some PUT _ALL_; statements (or PUTLOG in SAS 9) to help determine what is happening with the DATA step.

ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=1
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=2
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=3
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=4
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=5
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=6
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=7
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=8
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=9
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=10
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=11
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=12
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=13
ID=1235 KEYVAR=1235 _RBA_=80 _FDBK_=0 _RRN_=0 NAME=xxxxxxxxxx _ERROR_=0 _N_=14


This is keep on going.. until I cancel the job..

Also, are you getting CPU time and is there I/O activity -- information available from your JOB OUTPUT and from your batch job monitor (like SDSF)?

I am seeing I/O activity

Has this particular code worked in the past or is it the first attempt? And are you able to access the same file, say with IDCAMS?


This is our first attempt to process VSAM file. When I access the same file without key option, the code worked perfect. With KEY option, the program is looping
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Not sure what else to offer for diagnosing the problem, presuming the following DOC will not provide additional insight for your interest:

SAS Guide to VSAM Processing (Version 8):
http://support.sas.com/documentation/onlinedoc/base/vsam.pdf

Perhaps you have some other colleagues who use and/or maintain this VSAM file, and you can collaborate with them on your quest.

Good luck.

Scott Barry
SBBWorks, Inc.
esirjhm
Calcite | Level 5
Am I missing something? You are reading a keyed VSAM file and you never change the key and you are constantly getting the same record. If you don't change the key, why should you get a different record?
deleted_user
Not applicable
Great!... Thanks a lot... please correct my code. What should I add to stop as soon as reading the key?
Cynthia_sas
SAS Super FREQ
Hi:
The documentation is quite clear on the subject and has very good examples. See this link and READ the documentation.
http://support.sas.com/documentation/onlinedoc/base/vsam.pdf

You have to know whether you have a KSDS, ESDS or RRDS type of VSAM file in order to use the appropriate method in your code.

It is almost impossible for anyone to help you unless you understand what type of VSAM file you have and what type of read you want to do: sequential, or addressed direct access or direct address with alternate keys or skip sequential access or with read by relative record numbers.

Probably your best bet for help is to gather as much information about the VSAM file using documentation at your site and then contacting Tech Support for more help.

cynthia
esirjhm
Calcite | Level 5
Cynthia has a link to the documentation and it's good and you should read it, but here is something to play with while you are reading. This job creates a VSAM file and populates it with two records. And reads them back. Successfully. I get a condition code of zero, but I also get a diagnostic in SYSLOG and I'm not entirely sure what it is telling me:

ALL RECORDS READ
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+
3 0
GENKEY= FDBK=4 _RBA_=80 _FDBK_=4 _RRN_=0 KEYIN=22345 DATAN=SECOND RECORD _
NOTE: 2 records were read from the infile VSAMFILE.

In any case, if I can figure out what causes the diagnostic I'll be back. I haven't used VSAM in years.





//ESIRJHM6 JOB (6021,JHM,125,1500),CSECT,MSGCLASS=R,CLASS=4,
// TIME=NOLIMIT TYPRUN=SCAN
//IDCAMS EXEC PGM=IDCAMS
//REPRO DD *
12345 FIRST RECORD
22345 SECOND RECORD
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
DELETE 'ESIRJHM.VSAM.DATA'

DEFINE CLUSTER -
(NAME('ESIRJHM.VSAM.DATA') -
STORCLAS(ADVANCED) -
MGMTCLAS(STANDARD) -
CYL(2 1) -
KEYS(05 0)-
RECSZ(80 80))
REPRO ODS(ESIRJHM.VSAM.DATA) IFILE(REPRO)
VERIFY DATASET(ESIRJHM.VSAM.DATA)
SET MAXCC = 0
//SAS EXEC SAST
//VSAMFILE DD DISP=SHR,DSN=ESIRJHM.VSAM.DATA
//SYSIN DD *
OPTIONS NOCENTER;
DATA _NULL_;
LENGTH GENKEY $5;
FDBK = 0;
GENKEY = ' ';
INFILE VSAMFILE VSAM FEEDBACK=FDBK KEY=GENKEY GENKEY SKIP
KEYGE;
DO WHILE (FDBK = 0);
INPUT @;
IF FDBK = 0 THEN DO;
INPUT @01 KEYIN $5.
@06 DATAN $75.;
PUTLOG _INFILE_;
END;
END;
PUTLOG 'ALL RECORDS READ';
STOP;
RUN;
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Your end-of-file PUTLOG generated part of the diagnostic with the _INFILE_;

Simplify your DATA step by removing the DO loop. If you need to test FDBK, conditionally output if FDBK=0, and then use END=EOF DO/THEN if you need to generate some SASLOG end-of-processing messages.

Scott Barry
SBBWorks, Inc.
esirjhm
Calcite | Level 5
Scott,

I have pared the program down to this:
OPTIONS NOCENTER;
DATA _NULL_;
RETAIN GENKEY ' ';
INFILE VSAMFILE VSAM FEEDBACK=FDBK KEY=GENKEY GENKEY SKIP END=END
KEYGE;
INPUT @01 KEYIN $5.
@06 DATAN $75.;
IF END THEN STOP;
PUTLOG FDBK =;
IF FDBK = 0 THEN PUTLOG _INFILE_;
ELSE STOP;
RUN;


I still get the following diagnostic (though the return code is zero).

FDBK=4
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----
3 0
2 The SAS System

GENKEY= _RBA_=80 _FDBK_=4 _RRN_=0 FDBK=4 END=0 KEYIN= DATAN= _ERROR_=1 _INFI

Where is the third record coming from.

Why don't you just change the code to show me how to prevent this diagnostic.
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Frankly, how do you expect to learn, otherwise. Attaining an reputation as "experienced SAS programmer extraordinaire" through a burn-in phase requires self-diagnostic iteration -- something more than just trolling the Internet forums, I'd suggest. It's your program, your input data, your information processing requirement, programming composition, etc., therefore I encourage you to gain from what you learn here and go-forward. Others may have their own opinions and are free to share. I tend to guide rather than push.

To that end, I suggest you investigate each of your INFILE statement parameters, pare down your SAS code to the bare minimum, and run various GENKEY value scenarios, in order to learn from the SAS VSAM programming/processing behavior.

Good luck.

Scott Barry
SBBWorks, Inc.
deleted_user
Not applicable
Thanks so much for your replies.. I corrected the code, working fine..

//STEP0001 EXEC SAS
//INFIL DD DISP=SHR,DSN=XXXXX.SAI.TEST
//SYSIN DD *
DATA FILEIN;
ID='1235';
KEYVAR= ID;
INFILE INFIL VSAM KEY=KEYVAR FEEDBACK=CHK1;
INPUT
@5 NAME $CHAR12.;
PUT _ALL_;
IF CHK1 = 0 THEN DO;
OUTPUT;
STOP;
END;
ELSE DO;
PUT 'RECORD NOT FOUND..'
STOP;
END;
RUN;
PROC PRINT DATA=FILEIN;
;


The one option preventing from infinite loop is FEEDBACK check. One mystery still remaining is why SAS reading again and again same record for direct access using KSDS (example shown beginning of the topic)

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
  • 12 replies
  • 1395 views
  • 0 likes
  • 4 in conversation