Date: Thu, 17 May 2001 10:24:44 -0400
Reply-To: "Shilling, Brian [PRI]" <BShillin@PRIUS.JNJ.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Shilling, Brian [PRI]" <BShillin@PRIUS.JNJ.COM>
Subject: Re: Duplicate Records
Could you try something like this?
if 0 then set &sesslib..templim nobs=nobs;
%if &nobs ne 0 %then %do;
proc append base=&sesslib..baselim data=&sesslib..templim force;
proc append base=&sesslib..histouttab data=&sesslib..temphist
This way, the PROC APPEND will only happen when the dataset has obs in it.
HTH and is useful.
> -----Original Message-----
> From: Charles Brokmann [SMTP:cab@AIMSCO.COM]
> Sent: Thursday, May 17, 2001 10:20 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Duplicate Records
> Win2000Pro, V8.2
> I am running a proc shewhart (in a do loop from 1 to the # of phases):
> proc shewhart data=&sesslib..proctable;
> where _PHASE_ eq "¤tphase";
> &CHTTYPE &PROCVAR*&sub_group / outlimits=&sesslib..templim
> after which I append the templim and temphist to baselim and histouttab:
> proc append base=&sesslib..baselim data=&sesslib..templim force;
> proc append base=&sesslib..histouttab data=&sesslib..temphist
> The problem is that I don't want to append a record to these tables when
> the where clause in the proc shewhart returns 0 observations, like so
> (log excerpt):
> NOTE: No observations were selected from data set SESSLIB.PROCTABLE.
> NOTE: There were 0 observations read from the data set
> WHERE _PHASE_='03/27/01 15:37';
> NOTE: The data set SESSLIB.TEMPLIM has 0 observations and 0 variables.
> WARNING: Data set SESSLIB.TEMPLIM was not replaced because new file is
> NOTE: The data set SESSLIB.TEMPHIST has 0 observations and 0 variables.
> WARNING: Data set SESSLIB.TEMPHIST was not replaced because new file is
> However, the temp tables still have some records in them from the
> previous iteration of the loop, and those DUPLICATE records get appended
> to final tables anyway...
> Does anyone have any ideas how I can prevent these duplicate records
> from getting appended when nothing should be appended?