LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2009, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 12 Nov 2009 08:59:13 -0600
Reply-To:     Joe Matise <snoopy369@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Joe Matise <snoopy369@GMAIL.COM>
Subject:      Re: Asking for help~~~
Comments: To: Stanley Luo <shanminglo@gmail.com>
In-Reply-To:  <200911121018.nABKmPsC027538@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1

Are you using these for an analysis of some sort? If so, I suggest doing this as a view, and/or not doing it at all [you can put a BY variable that incorporates what you need, usually]. A view would save the storage space and disk write time while allowing you to subset still.

If you can assume a single record for each date, then this works. However, your example doesn't list 252 day periods; are they really weekdays or something? If so you'd need to adjust the number [you can use INTNX with 'WEEKDAY', for example].

%macro set_252(startd); data dset_&startd/view=dset_&startd; set twse_02_07; if ("&startd"d-252) < date <= ("&startd"d); run; %mend set_252;

This is much faster than creating full datasets, as long as you're not sending the dataset somewhere else.

Using INTNX for weekdays: %macro set_252(startd); data dset_&startd/view=dset_&startd; set twse_02_07; if intnx("WEEKDAY","&startd"d,252) < date <= ("&startd"d); run; %mend set_252;

-Joe

On Thu, Nov 12, 2009 at 4:18 AM, Stanley Luo <shanminglo@gmail.com> wrote:

> Dear SAS_Ls: > I want to create several datasets including 252 obs each from an given day > backward. > For example, from 2003/03/26 back to 2002/03/22 then output as dataset, > from 2003/07/09 back to 2002/07/05 then output as dataset. How do I > achieve that using macro syntax? > My original code is shown below > > DATA RDATE; > SET TWSE_02_07(FIRSTOBS=1 OBS=252); > WHERE '26MAR03'D >= DATE; > RUN; > > Thanks in advance!! >


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