| Date: | Thu, 9 Aug 2001 13:19:45 -0400 |
| Reply-To: | "Fehd, Ronald J." <rjf2@CDC.GOV> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | "Fehd, Ronald J." <rjf2@CDC.GOV> |
| Subject: | Re: Read data with 0 observations |
|
| Content-Type: | text/plain |
|---|
> From: Ji, Xinyu (DPH) [mailto:Xinyu.Ji@STATE.MA.US]
> Hi, I have the following do loop:
%LET TRANSCNT = 1;
%DO %WHILE &TRANSCNT;%*TEST OCCURS HERE;
%LET TRANSCNT = 0;
> DATA _NULL_;
> SET TRANSDATA NOBS = TRANS;
%*RESET ONLY IF NOBS GT 0;
> CALL SYMPUT('TRANSCNT', TRIM( LEFT(PUT(TRANS, 10.)) ));
> STOP;
> RUN;
> %END;
> That is, in each iteration, a data set TRANSDATA is
> generated. Repeat the do
> loop until TRANSDATA has no observations. However, when
> TRANSDATA actually
> has zero observation, DATA _NULL_ step will end at "SET
> TRANSDATA NOBS =
> TRANS;" statement, and "CALL SYMPUT('TRANSCNT', TRIM(
> LEFT(PUT(TRANS, 10.))
> ));" will not be executed. The previous TRANSCNT is not
> overwritten, and the
> do loop goes infinitely. Anyone could tell me how to fix the problem?
You understand the logic of the test correctly.
I've added a couple lines that should keep it going only until NOBS=0;
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
OpSys: Win_Pro Ver: 8.2
---> cheerful provider of UNTESTED SAS code from the KludgeWrx !*! <---
remember perspective: the error is not always where it seems to occur! --
RJF2
|