Getting a WARNING: Truncated record. but not able to figure out the reason

2k views Asked by At

I have a macro dt_query , which will be called with different parameters...

%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);

That macro is not creating any dataset but still getting this WARNING.Here is the code for dt_query macro....

%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

There are 2 answers

2
Quentin On

I have seen this warning before when I have a line of code that is really long. And SAS only reads the first N characters of the line. In this case I don't see any lines that are obviously too long. But would look in your original code and insert some breaks on the longest lines. If that doesn't work, I would probably start brute force debugging...

1
Bert Carremans On

Setting the linesize might solve your problem.

options LINESIZE=256;