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 (March 2011, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 3 Mar 2011 11:53:22 -0800
Reply-To:     "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject:      Re: Data manipulation
In-Reply-To:  <845010.12110.qm@web113614.mail.gq1.yahoo.com>
Content-Type: text/plain; charset=utf-8

> -----Original Message----- > From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of > Steve Steve > Sent: Thursday, March 03, 2011 10:35 AM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Data manipulation > > I have a dataset which keeps changing. It should have 5 variables, ae1- > ae5, but > sometime it has ae1, ae3 and ae4, sometime ae3, ae4 and ae5, and etc. I > should > fill in any missing ae* with 0. For example, I should have the > following output > for the dataset ae (see dataset below): > > Obs   id   ae1   ae2   ae3  ae4   ae5 > >  1    11    2     3     0    0     5 >  2    12    4     5     0    0     6 >  3    13    7     8     0    0     9 > > > Instead of the following: > > Obs   id   ae1   ae2   ae5 > >  1    11    2     3     5 >  2    12    4     5     6 >  3    13    7     8     9 > > > Thanks!!! > > > > > dataae; > inputid ae1 ae2 ae5; > cards; > 11 2 3 5 > 12 4 5 6 > 13 7 8 9 > ; > run; > > procprint;run; > >

Something like this should get you started,

data ae; retain ae1-ae5 0; input id ae1 ae2 ae5; cards; 11 2 3 5 12 4 5 6 13 7 8 9 ; run;

Hope this is helpful,

Dan

Daniel J. Nordlund Washington State Department of Social and Health Services Planning, Performance, and Accountability Research and Data Analysis Division Olympia, WA 98504-5204


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