Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

how to tell the pointer to go bac to the 1st rec in input

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
View previous topic :: :: View next topic  
Author Message
jm_green84

New User


Joined: 13 Dec 2006
Posts: 11
Location: ATL

PostPosted: Sat Jan 24, 2009 1:32 am    Post subject: how to tell the pointer to go bac to the 1st rec in input
Reply with quote

Can anyone help me out with this one?

I'm reading in a file and doing some checks on it before processing it. and I'm reading in my header record on line one and then going to line two to read in another var. Now once I have my second var from line two, how can I tell sas in the input statement to go back to line 1 again to get my third value?

My file consist of the first rec being the HEADER, it also has the File Creation date on this line. Next line (line 2) is were my detail record starts, with actual ppl data. and each row that starts with a "02" is a valid record. the number of detail records vary from file to file. next after all the detail records the last rec is a Trailer record. Now I'm doing these checks because we apparently have some invalid files on our system, and don't want to process them.

so a valid file would look like

HEADER 20090123
02johndoe
02janedoe
02 ex....
TRAILER

The problem I am having is
- first I'm checking to make sure the file is valid by make sur ethe first record is indeed a HEADER row

-second I'm checking, "02" row for detail records. By say ok if your first row is a HEADER and your 2nd row starts with a "02" then your mored than likely a valid file , and **heres where my code isn't working. I then want it to go back to record 1 and now pull the File Creation date.**

If anyone knows out to make the pointer go back in a INPUT statement plz help me out, Thanks.

Code:

DATA GOOD NOTVALID;                                               
 INFILE SASI1 END = NODATA;                                       
  BADGDG = %ADDTICKS(%FILEDATA(SASI1,1));                         
  INPUT @01 CHECK1  $CHAR6.@;                                     
    IF (CHECK1 = 'HEADER' AND _N_ ¬= 1) OR (CHECK1 ¬= 'HEADER' AND
       _N_ =1 ) THEN DO;                                         
       FLG='BADFILE';                                             
       OUTPUT NOTVALID;                                           
    END;                                                         
                                                                 
    ELSE IF CHECK1='HEADER' AND _N_ =1 THEN DO;                   
            INPUT / @01  REC02 $CHAR02.@;                         
         IF REC02 ¬= '02' THEN DO;                               
            FLG='BADFILE';                                       
            OUTPUT NOTVALID;                                     
         END;                                                     
     END;                                                         
                                                                 
 IF FLG ¬='BADFILE' THEN DO;                                     
    RETAIN FILEDT;                         
    INPUT    @01 CHECK1 $CHAR6.           
                @07 FILEDT YYMMDD08.@;       
      IF CHECK1='HEADER' THEN DO;         
       CREDAT = FILEDT;                   
      END;                                 
                                           
    ELSE DO;                               
       INPUT @04  SSN              $CHAR09.
             @26  TRANSID          $CHAR06.
             @32  RATE             17.;   
       OUTPUT GOOD;                       
    END;                                   
 END;                                     
%PRINTEM(GOOD,TEST=&TORP);                 
%PRINTEM(NOTVALID,TEST=&TORP);                 
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Sat Jan 24, 2009 2:12 am    Post subject:
Reply with quote

Why not just use a LAG function to retain the needed value(s) from the first read to the second read?
Back to top
View user's profile Send private message
jm_green84

New User


Joined: 13 Dec 2006
Posts: 11
Location: ATL

PostPosted: Sat Jan 24, 2009 2:33 am    Post subject:
Reply with quote

Thanks for the reponse,

I will try the LAG func, I actually never used it but anythings worth a try right now.

How does it work?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Sat Jan 24, 2009 2:48 am    Post subject:
Reply with quote

Code:
INPUT X ...
Y = LAG1(X) ;
causes Y to have the same values as X, just one observation later. So if X is read as 1, 2, 3, 4 ... then Y will have values missing, 1, 2, 3, ....
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Formating the Input file sreekusr DFSORT/ICETOOL 3 Fri Feb 17, 2017 10:40 pm
No new posts Submit job from Cobol with input data abdulrafi COBOL Programming 4 Wed Feb 01, 2017 12:41 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 37 Tue Dec 06, 2016 8:04 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 15 Thu Dec 01, 2016 8:28 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us