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 2007, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 24 Oct 2007 18:00:18 +0000
Reply-To:     Paul Dorfman <sashole@BELLSOUTH.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Paul Dorfman <sashole@BELLSOUTH.NET>
Organization: PDC
Subject:      Re: data manipulation step
Comments: To: Roel Straetemans <RSTRAETE@PRDBE.JNJ.COM>

Roel,

You have chosen the right path of avoiding a verbose explanation and showing the easily discernible pattern instead, the latter making it simple enough not only to give you what you want with your set range:step (4:1) but also generalize a bit:

data y ; do y = 1 to 11 ; output ; end ; run ;

%let range = 4 ; %let step = 1 ;

data trochoid ; ind ++ 1 ; do p = sum (p, 1) to sum (p, &range) ; if p > n then stop ; set y point = p nobs = n ; output ; end ; p +- (&range - &step + 1) ; run ;

Note that in the case range-step=1 (3:2, for instance), it might be more apt to call the output data set "cycloid", since then the next period would start with the value of Y where the preceding period left off.

Kind regards ---------------- Paul Dorfman Jacksonville, FL ----------------

-------------- Original message ---------------------- From: Roel Straetemans <RSTRAETE@PRDBE.JNJ.COM> > > Dear all, > > sorry for the vague subject but I honestly have no clear idea to better > describe my question. > > I have the following dataset A (for simplicity one variable, six records): > > Y > 1 > 2 > 3 > 4 > 5 > 6 > > And I want to make one new dataset B which takes blocks of four consecutive > Y records over a moving window of one record in such a way that B (IND is a > new variable that needs to be created) looks as follows: > > Y IND > 1 1 > 2 1 > 3 1 > 4 1 > 2 2 > 3 2 > 4 2 > 5 2 > 3 3 > 4 3 > 5 3 > 6 3 > > > Thanks in advance, > Roel


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