Date: Wed, 15 Jan 2003 12:04:54 -0800
Reply-To: "William W. Viergever" <wwvierg@ATTGLOBAL.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "William W. Viergever" <wwvierg@ATTGLOBAL.NET>
Subject: Re: find the 3rd wednesday of every month
In-Reply-To: <ykhV9.53$iw.88820@news.uswest.net>
Content-Type: text/html; charset="us-ascii"
<html>
At 10:59 AM 1/15/2003 -0700, Lonnie Hamm wrote:<br><br>
<blockquote type=cite class=cite cite>Anyone know of an easy way to find
the date associated with the 3rd<br>
wednesday of every month?<br><br>
In addition, I need to find the 2nd observation previous to the above
date.<br>
I suppose I could use proc expand to lead an indicator variable based on
the<br>
above date or perhaps using indicator variables in a data step with
the<br>
observations sorted in reverse order.<br><br>
Lonnie</blockquote><br><br>
Maybe something like:<br><br>
<font color="#0000FF">%let</font> mon = 1 ;<br>
<font color="#0000FF">%let</font> yr = 2003 ;<br>
<font color="#000080"><b>data</b></font>
<font color="#0000FF">_null_</font>;<br>
<font color="#0000FF">do</font> i = mdy ( &mon, <font color="#008080"><b>1</b></font>, &yr ) <font color="#0000FF">to</font> intnx ( <font color="#800080">'month'</font>, mdy ( &mon, <font color="#008080"><b>1</b></font>, &yr ), <font color="#008080"><b>0</b></font>, <font color="#800080">'E'</font> );<br>
dow = weekday ( i ) ;<br>
<font color="#0000FF">if</font> dow = <font color="#008080"><b>4</b></font> <font color="#0000FF">then</font> wed_flag + <font color="#008080"><b>1</b></font> ;<br>
<font color="#0000FF">if</font> wed_flag = <font color="#008080"><b>3</b></font> <font color="#0000FF">then</font> <font color="#0000FF">do</font> ;<br>
wed3 = i ;<br>
<x-tab> </x-tab><x-tab> </x-tab> <font color="#0000FF">leave</font> ;<br>
<x-tab> </x-tab> <font color="#0000FF">end</font> ;<br>
<font color="#0000FF">end</font> ;<br>
<font color="#0000FF">put</font> wed3= <font color="#008080">weekdatx.</font> ;<br>
<font color="#000080"><b>run</b></font> ;<br>
<br>
<div>------------------------------------------------------------</div>
<div>William W. Viergever Voice : (916) 483-8398</div>
<div>Viergever & Associates Fax : (916) 486-1488</div>
<div>Sacramento, CA 95825 E-mail : wwvierg@attglobal.net</div>
<div>------------------------------------------------------------</div>
<br>
</html>
|