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**/;
end;
print InverseC;
m=frequency[1];
*Big=J(nrow(DM),m,value);
test = j(nrow(InverseC),1,1);
Big=SurvivalM*t( InverseC[loc(test^=0)]);
print 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 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3.6571429 | 0 | 0 | 0 | 0 |
ROW5 | 0 | 0 | 0.9090909 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3.4285714 | 0 | 0 | 0 | 0 |
ROW6 | 0 | 0 | 0.8484848 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 3.2 | 0 | 0 | 0 | 0 |
ROW7 | 0 | 0 | 0.7878788 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 2.9714286 | 0 | 0 | 0 | 0 |
ROW8 | 0 | 0 | 0.7272727 | 0 | 0 |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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 |
sample code:
data have;
input row $ v1-v5;
cards;
r1 2 0 0 0 3
r2 5 3 0 0 8
;
proc sql noprint;
select catx(' ','sum(',name,') as',name) into : list separated by ','
from dictionary.columns
where libname='WORK' and memname='HAVE' and type='num';
create table temp as
select &list from have;
quit;
data _null_;
set temp;
length _list $ 4000;
array _x{*} _numeric_;
do i=1 to dim(_x);
if _x{i} eq 0 then _list=catx(' ',_list,vname(_x{i}));
end;
call symputx('drop',_list);
run;
data want;
set have(drop=&drop);
run;
proc print;run;
Obs row v1 v2 v5
1 r1 2 0 3
2 r2 5 3 8
sample code:
data have;
input row $ v1-v5;
cards;
r1 2 0 0 0 3
r2 5 3 0 0 8
;
proc sql noprint;
select catx(' ','sum(',name,') as',name) into : list separated by ','
from dictionary.columns
where libname='WORK' and memname='HAVE' and type='num';
create table temp as
select &list from have;
quit;
data _null_;
set temp;
length _list $ 4000;
array _x{*} _numeric_;
do i=1 to dim(_x);
if _x{i} eq 0 then _list=catx(' ',_list,vname(_x{i}));
end;
call symputx('drop',_list);
run;
data want;
set have(drop=&drop);
run;
proc print;run;
Obs row v1 v2 v5
1 r1 2 0 3
2 r2 5 3 8
Thanks, what do I do if I want the the columns to be V1, V2, V3 , without skippying numbers
Sorry, I don't understand your question. v3,v4 were deleted in my example because they have all zeros.
Thanks, do you know how to delete rows within proc iml. I created this matrix in proc iml and want to delete the rows of 1s
Sorry, I don't use proc iml.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.