Here is the code that I used trying to replace 99 and -99 with period "." using "do" loops (we are not allowed to use array in this exercise). However, the code I did only generates the replacing results in the result window, but 99 and -99 won't be replaced in the original data in the library I created. I have tried many times, but I don't why know the period won't replace 99 and -99 in the original data. I attached my code file here well. Please let me know if anyone can answer my questions. I attended my code as "hw2" and the data file as "exercise2" below. Thanks!!!! My code for the 1st and 2nd question (Only the code for 2nd question has issues): libname HW2 'C:\Users\Administrator\Desktop\BU_2019\BS 803\HW\HW2'; /*1.Read only the following variables into a matrix called CG: NACZZMS, NACCLMI, NACCZLMD, NACCDFT, NACCAGEB.*/ proc iml; /* read variables from a SAS data set into a matrix */ varNames = {"NACCZMMS" "NACCZLMI" "NACCZLMD" "NACCZDFT" "NACCAGEB"}; use hw2.exercise2; /* open data for reading */ read all var varNames into CG; /* create matrix with 5 cols */ close hw2.exercise2; print CG[c=varNames]; proc iml; /* read variables from a SAS data set into a matrix */ varNames = {"NACCZMMS" "NACCZLMI" "NACCZLMD" "NACCZDFT"}; use hw2.exercise2; /* open data for reading */ read all var varNames into CG; /* create matrix with 5 cols */ do j=1 to 4; do i=1 to nrow(CG); if CG[i,j]=-99 | CG[i,j]=99 then CG[i,j]=.; end; end; print CG[c=varNames]; quit;
... View more