获取警告:截断记录。但无法弄清楚原因

时间:2015-06-16 14:55:11

标签: sas sas-macro

我有一个宏dt_query,将使用不同的参数调用...

%let dt_start_date_sql = %dt_query(month,-1,sqlsvr);
65           %let dt_end_date_sql  = %dt_query(month,0,sqlsvr);
WARNING: Truncated record.
66           %let start_date1=%dt_query(month,-1,oracle);

那个宏没有创建任何数据集但仍然得到这个WARNING.Here是dt_query宏的代码......

%macro dt_query(interval,offset,useDbtype,quote=,date=,alignment=B)/minoperator;
%put Start macro dt_query(&interval,&offset,&useDbtype,quote=&quote,date=&date,alignment=&alignment);

 %local useFormat useQuote sasdate d interval_temp;

 %if %superq(date)=%str() %then %let date=&dt_sas;

 %if &useDbtype=%str() %then %let useDbtype=&dbtype;

 %let useDbtype=%upcase(&useDbtype);

 %let interval=%upcase(&interval);

 %let interval_temp=%scan(&interval,1,%str(.));

 %let pos=%sysfunc(anydigit(&interval_temp));

 %if &pos %then %let interval_temp=%substr(&interval_temp,1,%eval(&pos-1));

 %if %eval(&interval_temp in YEAR QTR MONTH WEEK DAY YEARLY QUARTERLY MONTHLY WEEKLY DAILY)=0 %then
 %do;

    %let errormsg1=&interval is not a valid date interval.;

    %put ERROR: &errormsg1;

    %let jumptoexit=1;

    %let d=;

    %goto EXIT;

 %end;

 %if %sysfunc(inputn(&offset,best.))=%str() %then
 %do;

    %let errormsg1=&offset is not a valid date offset.;

    %put ERROR: &errormsg1;

    %let jumptoexit=1;

    %let d=;

    %goto EXIT;

 %end;

 %if &useDbtype=%str() %then
 %do;

    /* If useDbtype is missing, assume we need a sas date string */

    %let useFormat=date9.;

    %let useQuote=Y;

    %let sasdate=1;

 %end;
 %else
 %if %eval(&useDbtype in DB2 SQLSVR ORACLE TERADATA) %then
 %do;

       %if &useDbtype eq DB2 %then
       %do;

          /*      date format is 'mm/dd/yyyy' */

          %let useFormat=mmddyy10.;

          %let useQuote=Y;

       %end;

       %else
       %if &useDbtype eq SQLSVR %then
       %do;

          /*      date format is  'mm/dd/yyyy' */

          %let useFormat=mmddyy10.;

          %let useQuote=Y;

       %end;
       %else
       %if &useDbtype eq ORACLE %then
       %do;

          /*      date format is 01-DEC-2011*/

          %let useFormat=date11.;

          %let useQuote=Y;

       %end;
       %else
       %if &useDbtype eq TERADATA %then
       %do;

          /*      date format is '2012-01-01'*/

          %let useFormat=yymmddd10.;

          %let useQuote=Y;
       %end;

 %end;
 %else
 %do;

    %let errormsg1=Unrecognized useDbtype value &useDbtype..;
    %let errormsg2=Must be one of DB2, SQLSVR, ORACLE, TERADATA.;

    %put;
    %put ERROR: &errormsg1;
    %put ERROR: &errormsg2;
    %put;

    %let jumptoexit=1;

    %let d=;

    %goto EXIT;

 %end;

 %if &quote ne %str() %then %let useQuote=&quote;

 %let d=%dt_date(date=&date,interval=&interval,format=&useFormat,offset=&offset.,alignment=&alignment,quote=&useQuote);

 %if &sasdate=1 %then %let d=%superq(d)D;

%EXIT:

 %unquote(%superq(d))

%put End macro dt_query - Date Value returned is %unquote(%superq(d));
%mend dt_query;

2 个答案:

答案 0 :(得分:1)

在我有一行非常长的代码之前,我已经看到了这个警告。 SAS只读取该行的前N个字符。在这种情况下,我看不到任何明显太长的线。但是会查看原始代码并在最长的行上插入一些中断。如果这不起作用,我可能会开始暴力调试......

答案 1 :(得分:0)

设置lineize可能会解决您的问题。

options LINESIZE=256;