3
votes

I get an odd error code while trying to get a DS2 thread up and running.

   proc ds2;
   thread work.th_ieb /overwrite=yes;
   dcl DOUBLE Beg_Jahr;
   METHOD RUN();
    set {select id, date
       from DATA
       };
    IF FIRST.id THEN DO;
    Beg_Jahr    = YEAR(DATE);
    OUTPUT;
    END;
 END;
endthread;
run;

The Error is:

ERROR: Compilation error.
ERROR: Illegal conversion for date or time type. Source line 34.

It works fine without the YEAR function. Any ideas?

2
Make sure that the type associated with the variable you've called date actually has a date type. In PROC DS2, there is actually a date data type, unlike in "traditional" SAS, where dates are stored as the number of days since January 1st, 1960.Alex A.
Even If I add 'dcl DATE date' its not running.user3614882

2 Answers

1
votes

Here is a full sample program I used to reproduce your issue and this version works at my site. One key change is the format of 'dt' using 11.0 instead of date9 in the sas source data. I could not make it work with date9 even though the SAS docs say it should.

data stuff;
  format dt 11.0 id 11.0;
    dt='01JAN2015'd;
    id = 1;
run;

proc ds2;
    thread work.th_ieb /overwrite=yes;
        dcl double Beg_Jahr;
        dcl date ds2_dt having format yymmdd10.;

        METHOD RUN();
          set {select id, dt
                 from stuff
                order by id
              };
          by id;

            ds2_dt = to_date(dt);
            put ds2_dt=;

            IF FIRST.id THEN DO;
                Beg_Jahr = year(dt);
                put beg_jahr=;
                OUTPUT;
            END;
        END;
    endthread;

    data;
        dcl thread th_ieb t_inst;

        method run();
          set from t_inst threads=2;
        end;
    enddata;
run;
0
votes

I freely admit that I don't fully understand all of the intricacies of DS2, but this solution works for me.

Change the name of the variable you've called date to something else since date is a keyword in DS2. DS2 is much pickier than base SAS about those things. Here I'll call the variable birthdt just for the sake of example.

Make sure that the date variable is numeric in the input dataset.

proc ds2;
    thread work.th_ieb / overwrite = yes;
        dcl double beg_jahr;
        method run();
            set {
                select id, birthdt
                from data
            };
            if first.id then do;
                beg_jahr = year(birthdt);
                output;
            end;
        end;
    endthread;
run;
quit;