<P>在网上比较容易找到一个破解了时间限制的<FONT face="Times New Roman">SAS8</FONT>版本,但是这版本用不了<FONT face="Times New Roman">EM</FONT>而且<FONT face="Times New Roman">today</FONT>函数的值也是不正确的。但是平常我们是需要用到时间值的,我写了个程序来弥补这个不足,用<FONT face="Times New Roman">sas</FONT>自身的功能来实现<FONT face="Times New Roman">today</FONT>函数的功能:</P>
<P><FONT face="Times New Roman"><o:p></o:p></FONT></P>
<P>用法:</P>
<P><FONT face="Times New Roman">1</FONT>在程序的开始加入以下代码:</P>
<P><FONT face="Times New Roman">  %include “path”;</FONT></P>
<P><FONT face="Times New Roman">path </FONT>是你存放程序的物理绝对路径。如果你放在<FONT face="Times New Roman">d:\ </FONT>则<FONT face="Times New Roman">path</FONT>就是<FONT face="Times New Roman">d:\todayV1.sas</FONT>了。</P>
<P>注意:这个程序会清除以前的<FONT face="Times New Roman">output</FONT>的,所以最好是先运行了程序再运行其他程序。</P>
<P><FONT face="Times New Roman">2</FONT>就是在开<FONT face="Times New Roman">SAS</FONT>的时候运行,把这个程序放到<FONT face="Times New Roman">SAS</FONT>的自动批处理文件中,这样就不会有清除有用<FONT face="Times New Roman">output</FONT>的危险了。</P>
<P><FONT face="Times New Roman"><o:p></o:p></FONT></P>
<P>这个程序会产生<FONT face="Times New Roman">3</FONT>个<FONT face="Times New Roman">macro</FONT>变量<FONT face="Times New Roman">,</FONT>如下表:</P>
<P>               name     : value                                <o:p></o:p></P>
<P align=left>            &today_date : 25Nov2006                          <o:p></o:p></P>
<P align=left>              &today      : "25Nov2006"d                      <o:p></o:p></P>
<P align=left>              &date       : 20061125                           <o:p></o:p></P>
<P>举例说明使用方法:</P>
<P><FONT face="Times New Roman">1.  </FONT>生成按日子排列的<FONT face="Times New Roman">dataset</FONT>;</P>
<P><FONT face="Times New Roman">data xx_&date;</FONT></P>
<P><FONT face="Times New Roman">dataset</FONT>的名字就是按<FONT face="Times New Roman">xx_20061125</FONT>的方式排列了。</P>
<P><FONT face="Times New Roman">2</FONT>.生成连续<FONT face="Times New Roman">N</FONT>个月的最后一天的日子;代码如下:</P>
<P align=left><B>%macro</B> month(N);<o:p></o:p></P>
<P align=left>data _null_;<o:p></o:p></P>
<P align=left>%do i = <B>0</B> %to %eval(&n.);<o:p></o:p></P>
<P align=left>call symput ("month&i.",put(intnx("month",&today.,-&i,"end"),yymmddn8.));<o:p></o:p></P>
<P align=left>%end; <o:p></o:p></P>
<P align=left>run;<o:p></o:p></P>
<P align=left><B>%mend</B>;<o:p></o:p></P>
<P align=left><o:p></o:p></P>
<P>%<B><I>month</I></B>(<B>2</B>);</P>
<P>
<br></P>
<P>程序版权没有,翻版不究。</P>
<P>不过,希望大家能保留我在程序中的版权信息。谢谢</P>
[此贴子已经被作者于2006-11-27 17:27:43编辑过]