I'm sorry if this is a bit long, but I want to try to be complete.
I'm writing a SAS program to extract data from a file under Z/OS 1.4 (mainframe). For some reason I'm getting some odd results.
The raw data input is the print output from a previous step. The data is variable length from 9 to 125 characters long. The data seem to be read ok as follows:
data delitems (keep=deldata) gdgdata (keep=deldata);
INFILE catlist length=linelength;
INPUT linedata 1-1 @ ;
datalength = linelength - 1;
input @2 catdata $varying125. datalength;
put @1 catdata;
As you can see I use a put to the log to let me see the data I'm reading. I then extract a data item based on a character in the data string:
b = index(catdata,'-');
b = b-1;
if b > 3 then do;
rectype = substr(catdata,1,b);
put @1 'this is the rectype after substr extract: '@;
I check the length of b as I don't want to bother with any record that is too small. The put here is to see the data that was extracted.
I follow that with an if then statement to double check my later select-when conditions.
if rectype =: 'VOLSER' then put 'The if statement found VOLSER';
if rectype = 'CLUSTER' then put 'The if statement found CLUSTER';
Then I go into my select. I'm only going to put a portion of it here of course. I'm looking for more than two rec types, but these do are enough to show my problem.
when ('CLUSTER') do;
put @1 rectype
'when logic ****';
dsname = substr(catdata,17,44);
deldata = ' DEL '||trim(dsname)||' CLUSTER';
when ('VOLSER') do;
put @1 'rectype is VOLSER';
put @1 catdata;
put @1 'extracting volser and unit';
volser = substr(catdata,19,6);
unit = substr(catdata,45,8);
put @1 volser
@30 'volser and unit';
put @1 'This is the rectype after otherwise fall thru '
Neither the if nor the when for 'VOLSER' are executing as true. Following is an extract of the log;
THIS IS THE RECTYPE AFTER SUBSTR EXTRACT: VOLSER ******
THIS IS THE RECTYPE AFTER OTHERWISE FALL THRU VOLSER
CLUSTER ------- UHDWN0.EXTRACT.MEDIUM
THIS IS THE RECTYPE AFTER SUBSTR EXTRACT: CLUSTER ******
THE IF STATEMENT FOUND CLUSTER
CLUSTER WHEN LOGIC ****
Can anyone think of something I'm doing wrong? Or something I could add that might help my problem.
RACF Technical Support