Date: Wed, 15 Dec 2004 13:42:51 -0800
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "David L. Cassell" <cassell.david@EPAMAIL.EPA.GOV>
Subject: Re: System variable for current obs
Content-type: text/plain; charset=US-ASCII
"Moud, Kamyar" <Kamyar.Moud@CIBC.CA> wrote:
> I am looking for a system variable that can tell me the current
> observation a PROC or DATA step in SAS are processing. Kind of like
> a counter telling me which observation SAS is looking at currently.
Hmm. Didn't we go through this a few days ago?
There is no such 'system' variable.
When you are in a DATA step, you can use the internal variable _N_
to check which record you're using. Assuming you are not altering
_N_ in any way (I'm talking to you here, Dorfman! :-). So, if you
are making a single pass sequentially through the data set, you can
have SAS tell you the number of records (SAS gets that at the start
of the DATA step from the header, if it is a stock SAS data set) and
then you can read off _n_ to know what proportion of the data set you
have moved through. But that isn't available outside the DATA step,
unless you keep passing that information out (through a pipe, or to
macro variables, or something like that).
There is no equivalent for procs. For many procs, you have to make
more than one pass through the data, so an 'observation counter'
variable would be meaningless. For many procs, there is a pass through
the data, followed by intensive calculations which may take longer than
the data-read itself. So the 'observation counter' idea would be
downright unhelpful if you wanted to know when those steps would end.
If you have a long sequence of DATA steps and procs, and you want to
'proportion completed' info back to another process, the best bet would
be to do some benchmarking to know (roughly) what proportion of the
prcoess each step takes. Then, at the end of each step, send another
update to the other process, with a new (approximate based on prior
value for the proportion completed.
Alternatively, you could re-think your entire process to speed it up
enough that you wouldn't need that time bar in the other process, or
else to convert it to a single DATA step (or a small number of DATA
steps only) so that you could in fact know how much of the process was
completed by the _N_ value.
David Cassell, CSC
Senior computing specialist