S******3 发帖数: 66 | 1 actually, hash can do it with some trick. it's pretty fast and does not
require much temporary space.
some pseduo code for your reference (you need rename date variables first).
I think it worth some dollars, at least WB!
/* check to see if the current record has a match in the hash object */
rc = lookup.find(key: id);
/* if a match is found... */
if rc = 0 then do;
/* check the dates - if comparison is true, output the row */
if 1<=intck('month', date_b, date_a)<=60 then output;... 阅读全帖 |
|
a*****e 发帖数: 159 | 2 on a.permno=b.permno and intck('month',a.date, b.date)=0 |
|
q**j 发帖数: 10612 | 3 不谢。其实R没有完善的date functions。所以这些都不方便。还不如用character来转
换。
这些零七八碎的小package,能不要就别用了。期待R推出类似于intnx, intck这样的强
大函数。
as.Date("2001-01-01")就行。你用paste把月日年拼凑好就行了。
of |
|
|
|
D******n 发帖数: 2836 | 6 create a .vim directory under you home directory(there is a dot before
vim)
and then create a syntax directory under it
and then create a sas.vim file under the syntax directory
==============sas.vim======================
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn case ignore
syn region sasString start=+"+ skip=+\\|\"+ end=+"+
syn region sasString start=+'+ skip=+\\|\"+ end=+'+
" Want region from 'cards;' to ';' to be captured (Bob Heckel)
sy... 阅读全帖 |
|
|
n*****1 发帖数: 172 | 8 use the intck function in the sql
base, |
|
o******l 发帖数: 3125 | 9 %let sambeg = %sysfunc(mdy(6, 30, 1985)) ;
%let samend = %sysfunc(mdy(12, 31, 2011));
%let nummon = %sysfunc(intck('month', &sambeg, &samend));
最后一行应该怎么改? 试过 %eval还是不行。
谢谢! |
|
o******l 发帖数: 3125 | 10 %let sambeg = %sysfunc(mdy(6, 30, 1985)) ;
%let samend = %sysfunc(mdy(12, 31, 2011));
%let nummon = %sysfunc(intck('month', &sambeg, &samend));
%macro overall;
%do i = 1 %to &nummon;
%let t = %sysfunc(intnx('month', &sambeg, &i, 'end'));
%months(&t, 6, 6);
%end;
%mend overall;
%overall;
在macro里面,要用到系统函数的时候,应该怎么用?
怎样修改上面的代码呢?
谢谢! |
|
l*********l 发帖数: 2371 | 11 %macro run_code;
*%let start=%sysfunc(inputn('01feb09'd,anydtdte9.));
*%let end=%sysfunc(inputn('01jun13',anydtdte9.));
%let start=%sysfunc(inputn('01dec11'd,anydtdte9.)); %put &start;
%let end=%sysfunc(inputn('01feb12'd,anydtdte9.));
/*determines the number of months between the two dates*/
%let dif=%sysfunc(intck(month,&start,&end));
%do i=0 %to &dif;
%let date =%sysfunc(putn(%sysfunc(intnx(month,&start,&i,b)),yymmn6.)
);
%let date2=%sysfunc(putn(%sysfunc(in... 阅读全帖 |
|
z*****h 发帖数: 111 | 12 求助高手,在sas中经常需要以下操作
proc sql;
create table tb as select
a.*, b.val
from left a left join right b
on a.ID=b.ID
and 1<=intck('month', b.date, a.date)<=60;
quit;
这个方法很慢,看了下用hash,貌似只能实现equality join. 有想过用proc expand
把left表中的每一个date扩展成整个过去的60个月,然后用date step merge 或者
hash. 这样就能把inequality join 变成 equality join, 但是不知道怎么实现。
请教proc expand 的方法怎么实现,另外如果有更好的方法,请不吝赐教! |
|
h*******n 发帖数: 458 | 13 楼上问的是把这一句
and 1<=intck('month', b.date, a.date)<=60;
变成WHERE。我觉得是可以的,效率哪个更高就不清楚了。直觉上是WHERE效率高。
另外,把一个record复制多遍可以这样做:
data new;
set old;
do i=1 to Ntimes;
retain var1 var2 … varM;
output;
end;
run;
不过复制后的DATE还是原来的值,没变。你可以产生一个新的DATASET,含你MERGE要用
的ID var,每个弄若干行(60个月的天数),再加一个DATE,在和上面CODE类似的循环
里用INTNX产生要的日期。然后MERGE。 |
|
a*******y 发帖数: 105 | 14 data A;
input records $ 1-50;
cards;
1/1/2011|5000,3/1/2013|8000
1/1/2011|5000,3/1/2011|8000,4/5/2012|3456
;
run;
data B; set A;
count=countw(records, ',');
if count >= 2 then do;
month2=input(scan(scan(records, count, ','),1,'|'), MMDDYY10.);
month1=input(scan(scan(records, count-1, ','),1,'|'), MMDDYY10.);
monthbetween=intck('Month',month1, month2, 'C');
end;
run; |
|