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
 

 

SAS report genration problem

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> All Other Mainframe Topics
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    Post subject: SAS report genration problem
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: 7992
Location: Bellevue, IA

PostPosted: Sat Aug 25, 2012 5:49 pm    Post subject:
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    Post subject: Reply to: SAS report genration problem
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    Post subject: Re: Reply to: SAS report genration problem
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    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 Problem reading GTF trace output danik56 ABENDS & Debugging 7 Thu Mar 16, 2017 1:02 pm
No new posts Easytrieve report shalem CA Products 4 Sun Feb 26, 2017 9:08 am
No new posts ROUNDED Problem with COMPUTE statement shalem COBOL Programming 11 Thu Feb 09, 2017 8:16 pm
No new posts SYMNAMES problem jacobdng DFSORT/ICETOOL 7 Thu Dec 22, 2016 7:47 am
No new posts Problem in writing Output file vickey_dw COBOL Programming 5 Mon Nov 14, 2016 11:14 pm


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