Date: Tue, 12 Sep 2000 01:25:08 +0200
Reply-To: Pedro <ganesh@EUSKALNET.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Pedro <ganesh@EUSKALNET.NET>
Organization: Euskaltel
Subject: Re: Use of DO WHILE reading with POINT
Content-Type: text/plain;
Fehd,
Many thanks for your help.
Manuel
Fehd, Ronald J. <rjf2@CDC.GOV> escribió en el mensaje de noticias
9D17D648E4EBD311AD45009027D0DF9353B169@mcdc-atl-64.cdc.gov...
> From: Pedro [mailto:ganesh@EUSKALNET.NET]
> Reading SAS data observation to observation with this instruction
> SET sas-file POINT
> It's possible to use DO WHILE instruction over each observation?
> This is the structure of my program:
> DATA
> DO UNTIL
> SET file POINT=
> DO WHILE
You don't know what you want to do yet,
so you have not explained what you want to do
to us.
So, here are a few examples of reading observations in a data set:
*1. basic SAS Supervisor does all the work;
DATA B;
set A;
*2. read quickly, by-pass SAS Supervisor;
DATA B;
do until(EndoFile);
set A end = EndoFile;
*if <some condition> then;
output;
end;
*some processing at end of file;
stop;*VERY IMPORTANT TO AVOID ENDLESS LOOP;
*note1 the use of the flag EndoFile and the end= option on the set
statement.;
*note2 note the conditional output;
*3. read quickly, another way;
DATA B;
do ObsNmbr = 1 to NmbrObs;*by 100;
set A
point = ObsNmbr
nobs = NmbrObs;
*if <some condition> then;
output;
end;
stop;*VERY IMPORTANT TO AVOID ENDLESS LOOP;
*note1 This is a sequential read, 1 to NmbrObs
to read file backwards:
do ObsNmbr = NmbrObs to 1 by -1;*by -100;
*note2 the variable ObsNmbr points to which observation, or row,
is being read. The examples in the manual use the <by 100> option
to pick a subset of the data.
programming note:
<DO WHILE> the condition is tested at the top of the loop
<DO UNTIL> the condition is tested at the end of the loop
hope this helps
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
---> cheerful provider of examples from the manual,
yet UNTESTED SAS code!*! <---