Hi Reeza.
I have tried with the variable year since i have data for 2010-2017 and the value is numeric i had som terrible results:
My goal is to create a SUR estimation model assuming equal coefficient across time periods.
%let yvar=COPD;
%let xvars=Healthexpenditure Share_18_66 Share67_ Healthcosts Healthcosts_cofinancing Costelderlyadults Incomefromtaxes Costsports Socioeconomicindex Vocationaleducation Furthereducation Westerns Nonwesterns Dailysmokers Heavysmokers Physicalactivity Unhealthydiet Alcohol Familycontact;
%let wset=wnykom94;
%let datset=final;
%let region=Kkode;
%let time=year;
libname wcat '/folders/myfolders/sasuser.v94';
data set1; set work.&datset;
data sety; set set1; by year;if first.year;
yearch=put(year,4.);
proc iml;
print 'SUR model, assuming equal coefficients across time periods',,;
use set1;
yname={&yvar};
read all var yname into y;
xname={&xvars};
incxname={'Constant'}||xname;
read all var xname into x0;
use sety;
read all var {'year'} into year;
read all var {'yearch'} into yearch;
use wcat.&wset;
read all var _NUM_ into w;
n=ncol(w);
do i=1 to n;
w[i,]=w[i,]/sum(w[i,]);
end;
n=nrow(w);
nt=nrow(y);
t=nt/n;
xc=j(nt,1,1)||x0;
k=ncol(xc); tk=t*k;
***********OLS estimation assuming common coefficients**************;
bols=inv(t(xc)*xc)*t(xc)*y;
e=y-xc*bols;
***SUR estimate assuming time-specific coefficients***************;
b=bols;
goon=1;
iter=0;maxiter=1000;
do while (goon=1);
sigma=j(t,t,0);
do i=1 to t;
do j=i to t;
s=t(e[(i-1)*n+1:i*n])*e[(j-1)*n+1:j*n]/n;
sigma[i,j]=s; sigma[j,i]=s;
end;
end;
sigmai=inv(sigma);
kc=ncol(xc);
del1=j(kc,kc,0); del2=j(kc,1,0);
do i=1 to t;
do j=1 to t;
del1=del1+sigmai[i,j]*t(xc[(i-1)*n+1:i*n,])*xc[(j-1)*n+1:j*n,];
del2=del2+sigmai[i,j]*t(xc[(i-1)*n+1:i*n,])*y[(j-1)*n+1:j*n,];
end;
end;
del1=inv(del1);
V=del1;
b1=del1*del2;
e=y-xc*b1;
dif=max(abs(b-b1));iter=iter+1;
b=b1;
if (dif<0.0001 | iter>maxiter) then goon=0;
end;
print iter dif;
vsur=v; bsur=b;
ypred=xc*bsur;
predset=y||ypred;
create predset from predset[colname={'y' 'ypred'}];append from predset;
stdbsur=sqrt(vecdiag(Vsur));
tsur=bsur/stdbsur;
esur=y-xc*bsur;
psur=2*(1-probnorm(abs(tsur)));
resultsur= bsur||stdbsur||psur;
resultsurname={'Estimate' 'std' 'p-value'};
resultsur=round(resultsur*1000)/1000;
print 'SUR estimation results',,yname,,
resultsur[rowname=incxname colname=resultsurname];