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
Content-Type: multipart/alternative;
Charles,
Could you try something like this?
data _null_;
if 0 then set &sesslib..templim nobs=nobs;
call symput("NOBS",put(nobs,3.));
run;
%if &nobs ne 0 %then %do;
proc append base=&sesslib..baselim data=&sesslib..templim force;
proc append base=&sesslib..histouttab data=&sesslib..temphist
%end;
This way, the PROC APPEND will only happen when the dataset has obs in it.
HTH and is useful.
Brian
> -----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
>
> SAS_Lers:
> 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
> outhistory=&sesslib..temphist
> outindex="¤tphase."
> outphase="¤tphase."
> &CTLOPTS
> &spec_limit_opts
> &tests
> &tests2
> ;
> run;
>
> 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
> force;
>
> 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
> SESSLIB.PROCTABLE.
> 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
> incomplete.
> NOTE: The data set SESSLIB.TEMPHIST has 0 observations and 0 variables.
> WARNING: Data set SESSLIB.TEMPHIST was not replaced because new file is
> incomplete.
>
> 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?
>
> Thanks,
> Charles
[text/html]
|