This is the code that I am using;
SurvivalM=J(nrow(survival1),1,1);
do i = 1 to n;
if censored=1 then SurvivalM=survival1; else if censored[1]=0 then SurvivalM=survival1; /*****Create a 1 by N -matrix of Survival ****/;
end;
print SurvivalM;
InverseC=J(nrow(survival1),1,1);
do i = 1 to n;
if censored=1 then InverseC=1/survival1; else if censored[1]=0 then InverseC=0; /*****survivalC is the imputed censored survival and set the real Survivalval to 1**/;
*InverseCC=J(nrow(survival1),1,1);
end;
print InverseC;
Big=SurvivalM*t(InverseC);
print BIG;
/*** for this code I want to delete all colums of BIG where row1 and col1 are zero ***/;
BIGG=J(nrow(BIGG),20,1);
do 1 to n;
if col[i,1]=0 then delete;
end;
print BIGG;
statement : ASSIGN at line 4338 column 1
4339 do 1 to n;
-
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, DATA, UNTIL, WHILE.
ERROR 200-322: The symbol is not recognized and will be ignored.
4340 if col[i,1]=0 then delete;
4341 end;
ERROR: END does not occur within DO group at line=4341 col=1.
4342 print BIGG;
ERROR: Matrix BIGG has not been set to a value.
statement : PRINT at line 4342 column 1
Use something like:
reduced=BIG[, loc( BIG[ 1,]^= 0 )];
so use the result of the loc function to pick out the list of columns required. The same technique can be used to remove zeros from the vector in one of your other questions.
Ian.
I created this matrix BIG
ROW1 | 0 | 0 | 1.0875421 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 4.1015873 | 0 | 0 | 0 | 0 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ROW2 | 0 | 0 | 1.030303 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3.8857143 | 0 | 0 | 0 | 0 |
ROW3 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3.7714286 | 0 | 0 | 0 | 0 |
ROW4 | 0 | 0 | 0.969697 | 0 | 0 | 0 | 0 | 0 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1.1428571 | 0 | 0 | 0 | 0 |
ROW16 | 0 | 0 | 0.2651515 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 |
ROW17 | 0 | 0 | 0.2272727 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.8571429 | 0 | 0 | 0 | 0 |
ROW18 | 0 | 0 | 0.1515152 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.5714286 | 0 | 0 | 0 | 0 |
ROW19 | 0 | 0 | 0.0757576 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0.2857143 | 0 | 0 | 0 | 0 |
ROW20 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
and want to create another matrix BIGG by deleting all the colums that have first element equal zero in BIG to produce the matrix BIGG.
This is the wrong code;
SurvivalM=J(nrow(survival1),1,1);
do i = 1 to n;
if censored=1 then SurvivalM=survival1; else if censored[1]=0 then SurvivalM=survival1; /*****Create a 1 by N -matrix of Survival ****/;
end;
print SurvivalM;
InverseC=J(nrow(survival1),1,1);
do i = 1 to n;
if censored=1 then InverseC=1/survival1; else if censored[1]=0 then InverseC=0; /*****survivalC is the imputed censored survival and set the real Survivalval to 1**/;
*InverseCC=J(nrow(survival1),1,1);
end;
print InverseC;
Big=SurvivalM*t(InverseC);
print BIG;
/*** for this code I want to delete all colums of BIG where row1 and col1 are zero ***/;
BIGG=J(nrow(BIGG),20,1);
do 1 to n;
if col[i,1]=0 then delete;
end;
print BIGG;
statement : ASSIGN at line 4338 column 1
4339 do 1 to n;
-
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, ;, DATA, UNTIL, WHILE.
ERROR 200-322: The symbol is not recognized and will be ignored.
4340 if col[i,1]=0 then delete;
4341 end;
ERROR: END does not occur within DO group at line=4341 col=1.
4342 print BIGG;
ERROR: Matrix BIGG has not been set to a value.
statement : PRINT at line 4342 column 1
Use something like:
reduced=BIG[, loc( BIG[ 1,]^= 0 )];
so use the result of the loc function to pick out the list of columns required. The same technique can be used to remove zeros from the vector in one of your other questions.
Ian.
Thanks, it work
Here is my advice: Your questions are all the same because you are working on a big problem. Do something easy like
u = 1:5;
v = {0,1,0,0,1};
Figure out how to do what you want with small vectors and matrices. After you understand the small simple case, the bigproblem will fall.
It will also make it easier for people on the discussion forum to answer your questions. A lot of people just hit the DELETE button if there isn't a short, simple, cut-an-paste example that illustrates the question.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how to run multiple linear regression models with and without interactions, presented by SAS user Alex Chaplin.
Find more tutorials on the SAS Users YouTube channel.