Date: Thu, 14 May 2009 20:24:31 -0500
Reply-To: Joe Matise <snoopy369@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Joe Matise <snoopy369@GMAIL.COM>
Subject: Re: Grap variable if condition one row down is met
In-Reply-To: <c9e97416-4e87-47c4-bf37-f43601b9150b@k19g2000prh.googlegroups.com>
Content-Type: text/plain; charset=ISO-8859-1
No, lag takes the variable name that you want to look at as the argument.
LAG() is one back, LAG2() is two back, etc. (up to 50 I believe).
set have; is the set statement; i'm assuming 'have' is the name of your
input dataset. If it's not in SAS yet, then you might have an easier time
using Art's suggestion, or a variation on that. Conditional input is
another option, depending on what the rest of the data looks like (reading
in, using @@ to hold the pointer, and then going back to the earlier spot if
you find something useful).
-Joe
On Thu, May 14, 2009 at 8:17 PM, EVANTRA <EDMOND.VANBEBBER@dts.ca.gov>wrote:
> On May 14, 3:17 pm, art...@NETSCAPE.NET (Arthur Tabachneck) wrote:
> > Can you just read them in at the same time? E.g.,
> >
> > data have;
> > infile cards truncover;
> > input tape_num junk $80./
> > status $80.;
> > if index(status,"1 RECORDS MARKED AS DELETED");
> > cards;
> > 102247 UNABLE TO DELETE, MUST BE SCRATCH STATUS
> > 1 RECORDS MARKED AS DELETED - TEST MODE ONLY
> > 102401 UNABLE TO DELETE, MUST BE SCRATCH STATUS
> > 0 RECORDS MARKED AS DELETED - TEST MODE ONLY
> > ;
> >
> > HTH,
> > Art
> > --------
> > On Thu, 14 May 2009 13:24:30 -0700, EVANTRA <EDMOND.VANBEB...@DTS.CA.GOV
> >
> > wrote:
> >
> >
> >
> >
> >
> > >On May 14, 11:11 am, gerhard.hellrie...@T-ONLINE.DE (Gerhard
> > >Hellriegel) wrote:
> > >> you must provide much more about that:
> > >> on what OS you are working? What are you trying to do exactly
> (program).
> > >> Is that a tape dataset or on disk? What means "grab a tape"? What do
> you
> > >> want to delete? What is the condition? Where is that text =" RECORDS
> > >> MARKED AS DELETED"? Is that a content of any variable? A SAS variable?
> >
> > >> Perhaps you could provide a example like:
> >
> > >> I have a dataset with that contents
> >
> > >> row1 ......
> > >> row2 ......
> > >> row3 ......
> >
> > >> in row 2 is the text 'bla bla' and a VolSer 0815. In that case there
> > >> should be a tape-mount and that tape 0815 should be deleted
> (scratched).
> >
> > >> I am on a zOS mainframe and I'm sure that my SAS session is allowed to
> > >> mount tapes and scratch them.
> >
> > >> I tried that with the following program:
> >
> > >> .....
> > >> .....
> >
> > >> The Log message was ... ( not only 2 lines without any context - I
> > assume
> > >> that WAS a log message? But where is ERROR: .... WARNING: .... , the
> > tape-
> > >> mount message, the libname / filename for the tape mount, ...?
> >
> > >> Gerhard
> >
> > >> On Thu, 14 May 2009 10:51:44 -0700, EVANTRA
> >
> > <EDMOND.VANBEB...@DTS.CA.GOV>
> >
> >
> >
> > >> wrote:
> >
> > >> >I'm trying to grab a tape(102247) if one row down =" RECORDS MARKED
> AS
> > >> >DELETED". I'm somewhat of a SAS newbie but it looks like a Retain
> > >> >might be the way to go but have never used it. Any ideas? Thanks in
> > >> >advance.
> >
> > >> >102247 UNABLE TO DELETE, MUST BE SCRATCH STATUS
> > >> > 1 RECORDS MARKED AS DELETED - TEST MODE ONLY- Hide
> > quoted text -
> >
> > >> - Show quoted text -
> >
> > >Thanks for the help Gerald, I will try to give more details.
> >
> > >We are running a TMS report that generates a disk dataset with a list
> > >of tapes and their status. I need to extract only the tapes out of
> > >the report that are marked "1 RECORDS MARKED AS DELETED". The problem
> > >I'm having is that this message is not on the same row as the
> > >corresponding tape so how do I pull the tape number one row up when
> > >the variable = "1 RECORDS MARKED AS DELETED"? How this helps and
> > >makes sense. Thanks
> >
> > >Row1 102247 UNABLE TO DELETE, MUST BE SCRATCH STATUS
> > >Row2 1 RECORDS MARKED AS DELETED - TEST MODE
> > >ONLY
> >
> > >Row3 102401 UNABLE TO DELETE, MUST BE SCRATCH STATUS
> > >Row4 0 RECORDS MARKED AS DELETED - TEST MODE
> > >ONLY- Hide quoted text -
> >
> > - Show quoted text -- Hide quoted text -
> >
> > - Show quoted text -
> Thanks for the input Art and Joe...I think I understand the concepts.
> I will try give these a shot and post my results.
>
> Joe, in my case, I need to look back one line so using your example of
> lag_val = lag(val); would my coding look something like lag_val = lag
> (1)? Also, what is the 'set have;'
>
> Thanks again
>
|