Date: Tue, 7 Sep 2010 16:49:48 -0400
Reply-To: Mike Rhoads <RHOADSM1@WESTAT.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Mike Rhoads <RHOADSM1@WESTAT.COM>
Subject: Re: Extracting the Tuesday after the 3rd Friday
In-Reply-To: <201009072040.o87AkeOL012444@malibu.cc.uga.edu>
Content-Type: text/plain; charset="us-ascii"
Art,
I assume that any numeric expression that returns a within-range value (e.g. 1-12 for month) should be fine. Your code worked for me with the following preliminary DATA step:
data have;
input TradingDate yymmdd8.;
cards;
20100119
20100130
20100720
20100731
run;
Mike
-----Original Message-----
From: Arthur Tabachneck [mailto:art297@NETSCAPE.NET]
Sent: Tuesday, September 07, 2010 4:40 PM
To: SAS-L@LISTSERV.UGA.EDU; Mike Rhoads
Subject: Re: Extracting the Tuesday after the 3rd Friday
Mike,
Thanks! I didn't know about that function. I can't test it as I don't
have 9.2, but will it take functions and variables? I.e., in the case of
the OP, could he use?:
data want;
set have;
format TradingDate weekdatx32.;
where TradingDate eq
NWKDOM(3, 6, month(TradingDate),year(TradingDate)) + 4;
run;
Art
----------
On Tue, 7 Sep 2010 16:22:51 -0400, Mike Rhoads <RHOADSM1@WESTAT.COM> wrote:
>If you're lucky enough to be running SAS 9.2, there's a new function
specifically designed for identifying things like the 3rd Friday of a
particular month:
>
>NWKDOM -- returns the date for the nth occurrence of a weekday for the
specified month and year
>
>NWKDOM(3, 1, 6, 2010) returns 20JUN2010 (3rd Sunday, since Sunday is "day
1" of each week)
> Value of 5 for 1st argument means last week of the month
>
>
>Mike Rhoads
>RhoadsM1@Westat.com
>
>
>-----Original Message-----
>From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Arthur Tabachneck
>Sent: Tuesday, September 07, 2010 11:18 AM
>To: SAS-L@LISTSERV.UGA.EDU
>Subject: Re: Extracting the Tuesday after the 3rd Friday
>
>Rob,
>
>I missed the part of your request that said you want to "extract"
>those records which meet the condition. However, I'd still propose
>the same calculation, just using it in a where statement. E.g.,:
>
>data want;
> set have;
> format TradingDate weekdatx32.;
> where TradingDate eq
> /*3rd Friday of each month*/
> intnx('week.6',
> mdy(month(TradingDate),1,year(TradingDate))-1,3)
> /*+4 to = following Tuesday*/ +4;
>run;
>
>HTH,
>Art
>------------
>On Sep 6, 3:14 am, Rob Roszkowski <rob.roszkow...@gmail.com> wrote:
>> Hi everyone,
>>
>> I am using daily time series data and I would like to extract those
>> observations that lie on the Tuesday (after the 3rd Friday of the
>> month). Does anyone know how to do this? From what I have researched
>> so far, it looks like maybe date functions is a possible solution.
>>
>> Many Thanks in advance for any advice.
|