Yes, I think this will work, thanks. My #2 desired wasn't right- looks like it should have had one more gap filled in.
--- email@example.com wrote:
From: Joe Matise <firstname.lastname@example.org>
Subject: Re: Filling in Gaps?
Date: Wed, 21 Apr 2010 11:07:17 -0500
In any event if it is straightforward, then does this work?
infile cards missover;
input id day1 day2 day3 day4 day5 day6 day7 day8 day9 day10 day11 day12;
001 1 1 1 1 2 2 . . . . 1 1
002 2 2 2 . 1 . . . . . 1 .
array days day:;
do _t = 1 to dim(days);
if days[_t] > 1 then do;
extra = extra + days[_t] - 1;
days[_t] = 1;
else if days[_t] < 1 and extra ge 1 then do;
days[_t] = 1;
extra = extra - 1;
It replicates id #001 but does not match id #002. If that's wrong can you
explain what's happening to id#002?
On Wed, Apr 21, 2010 at 11:04 AM, Joe Matise <email@example.com> wrote:
> Mary, just so I understand, can you take a quick look at the data you
> posted? I see twelve days not ten, and I don't understand how you decided
> to fill in some gaps and not others on ID #2 (it looks like you have at
> least one extra pill). Is this a straightforward 'fill forward' problem, or
> is there anything else going on?
> On Wed, Apr 21, 2010 at 11:10 AM, Mary <firstname.lastname@example.org> wrote:
>> I've got a data set like this:
>> data test2;
>> infile cards missover;
>> input id day1 day2 day3 day4 day5 day6 day7 day8 day9 day10;
>> 001 1 1 1 1 2 2 . . . . 1 1
>> 002 2 2 2 . 1 . . . . . 1 .
>> These are the number of pills someone has on hand each day. What I want
>> is to fill in the gaps with the extra pills on hand, so I want a result like
>> 001 1 1 1 1 1 1 1 1 . . 1 1
>> 002 1 1 1 1 1 1 . . . . 1 .
>> Ideas would be appreciated; I'd like to keep this wide rather than
>> transpose it long if possible.