Hey to all, I would like to know how to delete in array and matrix using sas proc fcmp. And also, I wanted to know if can call the same subroutine such I did at line 49. Here is the code I made. Regards proc fcmp outlib=work.func.matrix;
subroutine GSPfunc(mat[*,*],GSP[*,*]);
outargs GSP;
epsilon= 10 ** -10;
array vectors{1,1} _temporary_;
array t_vectors{1,1} _temporary_;
call dynamic_array(vectors, dim(mat,1),dim(mat,1));
call dynamic_array(t_vectors, dim(mat,1),dim(mat,1));
array values{dim(mat,1)} _temporary_;
array mat2{1,1} _temporary_;
call dynamic_array(mat2, dim(mat,1),dim(mat,1));
/*Calculation of Eigenvecteurs and Eigenvalues by suroutine Jacobi*/
call jacobi(mat,values,vectors,nrot);
do i= dim to 1 by -1;
if values[i]<= epsilon then do;
if values[i]< -epsilon then IsNegative= 1 do;
delete /* value[i] ?*/; delete /*vectors[i,.] ?*/; /*HELP ME HERE: I want to delete the value[i] and the corresponding vectors[i,.]*/
end; end;
else do;
do j= dim to 1 by -1;
vectors[j,i]= vectors[j,i] * sqrt(values[i]);
end;
end;
end;
if IsNegative= 1 then do; /*In this case, I'm bulding a new matrix: mat2, that is set with mat without vectors[i,.]*/
call transpose(vectors, t_vectors);
call mult(vectors, t_vectors, mat2);
do i= 1 to dim(mat2,1);
mat2[i, i] = Sqrt(mat2[i, i]);
end;
do i= 1 to dim(mat2,1)-1;
do j= i+1 to dim(mat2,1);
mat2[i,j]= mat2[i,j] / (mat2[j,j] * mat2[i, i]);
mat2[j,i]= mat2[i,j];
end;
end;
do i= 1 to dim(mat2,1);
mat2[i,j]= 1;
end;
/*repete all the process on mat2*/
do i= 1 to dim(vectors,1);
do j= 1 to dim(vectors,2);
GSP[i,j] = GSPfunc(mat2,GSP];
end;
end;
end;
else if IsNegative ne 1 then do;
do i= 1 to dim(vectors,1);
do j= 1 to dim(vectors,2);
GSP[i,j] = vectors[i,j];
end;
end;
end;
endsub;
run;
... View more