Date: Wed, 20 Mar 2002 11:00:51 -0500
Reply-To: Quentin McMullen <QuentinMcMullen@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Quentin McMullen <QuentinMcMullen@WESTAT.COM>
Subject: Re: Repeated observations
Content-Type: text/plain; charset="iso-8859-1"
Neal K Nair [mailto:nnair@ACF.DHHS.GOV] wrote:
> Sent: Wednesday, March 20, 2002 9:31 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Repeated observations
> Dear colleagues:
> Please see the SAS alert note below:
> SN-007104 ***Alert Note***
> Incorrect results with FREQ and/or WEIGHT statement when DIST=NEGBIN
> Product: SAS/STAT
> Component: GENMOD
> Priority: ALERT
> If you use a WEIGHT and/or FREQ statement in conjunction with the
> DIST=NEGBIN option in the MODEL statement, all results will be
> To circumvent the problem, if you are using a FREQ
> statement, generate
> repeated observations rather than using the FREQ statement.
> There is no
> circumvention if you are using a WEIGHT statement. "
> My question: How can we generate 'repeated observations'?
> Is there a SAS
> statement, or function, or whatever else to do it?
> Thanks for any suggestions.
If you are using the FREQ statement then you have a variable in your dataset
which indicates the number of observations that a single record
"represents". So to expand the data you can put an output statement in a
do-loop, outputing each record as many times as specified by your frequency
variable, as below. Note that missing and negative values of the frequency
variable should result in no data being output, as with the FREQ statement.
Also, any non-integer values will be treated as if truncated to an integer
(as with FREQ statement).
input x freqvar;
94 data b;
95 set a;
96 if missing(freqvar) then freqvar=0; *treat missing as 0, as freq
97 do i=1 to freqvar;
98 put _all_;
x=1 freqvar=2 i=1 _ERROR_=0 _N_=1
x=1 freqvar=2 i=2 _ERROR_=0 _N_=1
x=2 freqvar=4 i=1 _ERROR_=0 _N_=2
x=2 freqvar=4 i=2 _ERROR_=0 _N_=2
x=2 freqvar=4 i=3 _ERROR_=0 _N_=2
x=2 freqvar=4 i=4 _ERROR_=0 _N_=2
NOTE: There were 5 observations read from the data set WORK.A.
NOTE: The data set WORK.B has 6 observations and 3 variables.