Reputation: 195
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?
Upvotes: 3
Views: 735
Reputation: 321
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;
Upvotes: 1
Reputation: 5586
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;
Upvotes: 0