0

我很难让 INTCK 函数返回我正在使用以下查询的结果

proc sql;
CREATE TABLE SASAVE.WEEK_NUM AS
SELECT DISTINCT MUC.CODE
        ,MUC.LOB
        ,MMD.MAX_DATE
        ,MMD.MIN_DATE
        ,INTCK('WEEK', MMD.MAX_DATE, MMD.MIN_DATE) AS WEEK_COUNT
FROM    SASAVE.MUC,
        MMD             
WHERE MMD.LOB = MUC.LOB
AND MMD.CODE = MUC.CODE
quit;

这是 MUC 和 MMD 表中的数据

 **MMD**
    MIN_DATE         MAX_DATE       CODE    LOB
    13FEB2012   11MAY2012   527A    TMZ
    13FEB2012   1MAY2012    TB50    ZAE
    13FEB2012   10MAY2012   3O05    ZAA

**MUC**
CODE      LOB
527A    TMZ
TB50    ZAE
3O05    ZAA

请告诉我是否可以使用 INTCK 函数获取周数

谢谢

4

1 回答 1

2

好像你几乎是对的……这行得通。

Data mmd;
 input min_date:DATE9. max_date:date9. code $ lob $;
 format min_date max_date mmddyy10.;
 datalines;
13FEB2012   11MAY2012   527A    TMZ
13FEB2012   01MAY2012    TB50    ZAE
13FEB2012   10MAY2012   3O05    ZAA
;

Data muc;
 input code $ lob $;
 datalines;
527A    TMZ
TB50    ZAE
3O05    ZAA
;

proc sql;
 CREATE TABLE WEEK_NUM AS
 SELECT DISTINCT MUC.CODE
  ,MUC.LOB
  ,MMD.MAX_DATE
  ,MMD.MIN_DATE
  ,INTCK('WEEK', MMD.MIN_DATE, MMD.MAX_DATE) AS WEEK_COUNT
 FROM MUC, MMD             
 WHERE MMD.LOB = MUC.LOB
  AND MMD.CODE = MUC.CODE;
quit;
于 2012-05-13T16:08:37.520 回答