LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (April 2010, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Wed, 21 Apr 2010 09:11:29 -0700
Reply-To:   mlhoward@avalon.net
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Mary <mlhoward@AVALON.NET>
Subject:   Re: Filling in Gaps?
Comments:   To: Joe Matise <snoopy369@gmail.com>
Content-Type:   text/plain; charset="UTF-8"

Yes, I think this will work, thanks. My #2 desired wasn't right- looks like it should have had one more gap filled in.

-Mary

--- snoopy369@gmail.com wrote:

From: Joe Matise <snoopy369@gmail.com> To: mlhoward@avalon.net Cc: SAS-L@listserv.uga.edu 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?

data test2; infile cards missover; input id day1 day2 day3 day4 day5 day6 day7 day8 day9 day10 day11 day12; cards; 001 1 1 1 1 2 2 . . . . 1 1 002 2 2 2 . 1 . . . . . 1 . ; run;

data want; set test2; array days day:; extra=0; do _t = 1 to dim(days); if days[_t] > 1 then do; extra = extra + days[_t] - 1; days[_t] = 1; end; else if days[_t] < 1 and extra ge 1 then do; days[_t] = 1; extra = extra - 1; end; end; run;

It replicates id #001 but does not match id #002. If that's wrong can you explain what's happening to id#002?

Thanks,

Joe

On Wed, Apr 21, 2010 at 11:04 AM, Joe Matise <snoopy369@gmail.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? > > Thanks, > > Joe > > > On Wed, Apr 21, 2010 at 11:10 AM, Mary <mlhoward@avalon.net> wrote: > >> Hi, >> >> 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; >> cards; >> 001 1 1 1 1 2 2 . . . . 1 1 >> 002 2 2 2 . 1 . . . . . 1 . >> ; >> run; >> >> 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 >> this: >> >> 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. >> >> -Mary >> > >


Back to: Top of message | Previous page | Main SAS-L page