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 (October 2008, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Sun, 26 Oct 2008 10:24:48 -0400
Reply-To:   Ken Borowiak <EvilPettingZoo97@AOL.COM>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Ken Borowiak <EvilPettingZoo97@AOL.COM>
Subject:   Re: fill up dataset with rows
Content-Type:   text/plain; charset=ISO-8859-1

On Sun, 26 Oct 2008 09:40:05 -0400, kwu0914 <kwu0914@GMAIL.COM> wrote:

>Guess you objective is to fill the missing rows for each group (1 or 2, mybe >more), following is a demonstration, you can customize it to fullfil your >needs. > >data tmp (keep=group a); > do i = 1 to 2; > group = i; > do j = 1 to 5; > a = 0; > output; > end; > end; >run; >

While the dataset TMP has the desired number of records, values and order, the generation of it can be cleaned up some.

1) The index I and assignment statement for GROUP can be consolidated 2) Assignment of value for variable A should be moved outside of the DO block. The value of A is independent of what happening within the DO block. Placing the assignment of A within the DO block violates the Golden Rule of Repetitious Coding ( http://analytics.ncsu.edu/sesug/2002/TU05.pdf ).

data tmp (keep=group a); a=0 ; do group = 1 to 2 ; do j = 1 to 5 ; output; end; end; run ;

pax, Ken Borowiak

>data want; > merge tmp test; > by group; >run; > > >"Peter M"??ller"" <mortal@GMX.LI> wrote in message >news:200810261119.m9QAmIBV020533@malibu.cc.uga.edu... >> Hello to the list members! >> >> >> I have got a dataset with 2 groups with differing N. >> >> I need to fill up the second group with the value zero for variable b and >> need to fill up group 2 for the variable a, so that both groups have five >> entries: >> >> >> data* test; >> input group a ; >> cards; >> 1 4 >> 1 3 >> 1 2 >> 1 1 >> 1 0 >> 2 1 >> 2 0 >> ; >> run; >> >> >> >> I need >> >> group a >> >> 1 4 >> 1 3 >> 1 2 >> 1 1 >> 1 0 >> 2 1 >> 2 0 >> new additional wanted: >> 2 0 >> 2 0 >> 2 0 >> ; >> >> thank you very much! >> >> >> Peter Müller


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