Have you made any progress on this by using the steps I outlined? Here is an IML program I wrote over the weekend, in case it is helpful. I hard-coded the check for the case where only two parameters (Intercept and t) are valid :
libname com 'put_your_ path_here';
proc iml;
start GetLowerTriang(A);
idx = loc(col(A) <= row(A));
return A[idx];
finish;
varNames = {"Intercept" "t" "Cravingcw_Lag1" "Cravingcw_Lag2"};
use com.cov_id; /*cov_id1 is the name of the dataset output from the proc reg ods output statement requesting covb */
read all var "ID";
read all var "Variable";
read all var varNames into AllCov;
close;
/* https://blogs.sas.com/content/iml/2011/11/07/an-efficient-alternative-to-the-unique-loc-technique.html
*/
b = uniqueby(ID, 1); /* b[i] = beginning of i_th category */
b = b // (nrow(ID)+1); /* trick: append (n+1) to end of b */
P = ExpandGrid(varNames, varNames);
PairMat = shape( rowcatc(P[,1] + "_" + P[,2]), ncol(varNames));
AllPairNames = GetLowerTriang(PairMat);
print AllPairNames;
PairNames2 = GetLowerTriang(PairMat[1:2,]);
print PairNames2;
PairNames = AllPairNames; /* initialize length */
create cov_rows var {"SubjID" "PairNames" "Cov"};;
do i = 1 to nrow(b)-1; /* 4. For each level... */
idx = b[i]:(b[i+1]-1); /* 5. Find observations in level */
NN = ncol(idx);
C = AllCov[idx,]; /* the covariance matrix */
Cov = GetLowerTriang(C); /* 6. Compute statistic on those values */
SubjID = repeat(ID[b[i]], nrow(Cov));
if NN = 2 then
PairNames = PairNames2;
else
PairNames = AllPairNames;
append;
end;
close cov_rows;
quit;
... View more