0

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;
Joe
  • 62,789
  • 6
  • 49
  • 67
SAS_learner
  • 521
  • 1
  • 13
  • 30
  • Do you get the warning every time you call the macro? Or in your example, does only the first call generate the warning? – Quentin Jun 16 '15 at 21:07
  • 1
    Your code depends on another macro, `%dt_date`, for which you have not provided the source code. Please provide a complete and minimal section of code that produces the error you're seeing. – user667489 Jun 16 '15 at 21:21
  • @Quentin :I'm not getting this WARNING every time....this is happening once a while. – SAS_learner Jun 18 '15 at 13:42
  • With the same macro call does it happen consistently? How about as a batch job? I would try to replicate the problem consistently in a small batch job. It's tough to debug without being able to do that. – Quentin Jun 18 '15 at 14:02

2 Answers2

1

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...

Quentin
  • 5,960
  • 1
  • 13
  • 21
0

Setting the linesize might solve your problem.

options LINESIZE=256;
Bert Carremans
  • 1,623
  • 4
  • 23
  • 47
  • I'm a SAS newbie, but FYI, I just tried a script of mine with and without `-LINESIZE MAX` (as an command line argument to SAS.exe) and the input line got truncated in the same place. However, the output file (LOG) word-wrapped at a different width. – daveloyall Oct 22 '20 at 00:31