IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

SAS report genration problem


IBM Mainframe Forums -> All Other Mainframe Topics
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
goran

New User


Joined: 27 Aug 2010
Posts: 2
Location: Chennai

PostPosted: Sat Aug 25, 2012 5:32 pm
Reply with quote

Hi,
This is my first post to this forum and I tried searching my problem in other topics but couldn't find it.
I am very new to SAS programming and wrote few report creation program based on existing ones but I am facing a problem with a new one now.

My requirement is to read from 2nd last line if a particular string is found in the current file read pointer.
Is there any specific function/command in SAS if I can do it. Or need to read the file twice (first to calculate the required row then to fetch the line required ) Or is there any other easy way. I am looking into SAS manuals for sometime but if anyone can help I will be grateful.

Thanks,
goran
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Aug 25, 2012 5:49 pm
Reply with quote

You can use the LAG1 function in SAS to hold an observation over to the next observation. So something like this should work for your need:
Code:
DATA X;
     INFILE DD01 END=EOF;
     INPUT @001 DATALINE $CHAR<fill in length of record>;
     HOLDLINE = LAG1(DATALINE) ;
     <other logic>
     IF  EOF
     THEN DO;
          <HOLDLINE has the next-to-last line's data so use it as needed>
          END;
Back to top
View user's profile Send private message
goran

New User


Joined: 27 Aug 2010
Posts: 2
Location: Chennai

PostPosted: Mon Aug 27, 2012 4:58 am
Reply with quote

Hi Robert,

Thank you very much for the reply! what I understood is that LAG3 will be needed for this scenario..

Cheers,
goren
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Aug 27, 2012 5:35 am
Reply with quote

goran wrote:
Hi Robert,

Thank you very much for the reply! what I understood is that LAG3 will be needed for this scenario..

Cheers,
goren


well, I am sure that you have tested it,
so which one works, LAG1 or LAG3?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> All Other Mainframe Topics

 


Similar Topics
Topic Forum Replies
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Need help on formatting a report DFSORT/ICETOOL 14
No new posts Creating Report using SORT DFSORT/ICETOOL 7
No new posts Ca7 long running jobs report All Other Mainframe Topics 1
No new posts Report of batch jobs JCL & VSAM 1
Search our Forums:

Back to Top