s******1 发帖数: 178 | 1 Dear all,
I have a SAS question needed to help. I have 20 variables a1-a10 and b1-b10
and want to fit a logistic regression but use the different combinations and
get odds ratio or estimate.
SAS code: how could get all 100 combination models????? Thanks so much!!!!
%macro logisticm (a=, b=, outdsn= );
ODS OUTPUT OddsRatios=&outdsn;
proc logistic data=one desc;
model iiq1=&a &b age;
run;
ODS OUTPUT CLOSE;
%mend;
%logisticm (a=a1, b=b1, outdsn=a1);
%logisticm (a=a1, b=b2, outdsn=a2);
.....
%logisticm (a=a2, b=b1, outdsn=a3);
%logisticm (a=a2, b=b2, ,outdsn=a4);
.....
..... | k*******a 发帖数: 772 | 2 可以用循环啊,比如
%do i=1 %to 10;
%do j=1 %to 10;
ODS OUTPUT OddsRatios=outa&i.b&j;
proc logistic data=one desc;
model iiq1=a&i b&j age;
run;
ODS OUTPUT CLOSE;
%end;
%end; | s******1 发帖数: 178 | 3 Thank you very much!
【在 k*******a 的大作中提到】 : 可以用循环啊,比如 : %do i=1 %to 10; : %do j=1 %to 10; : ODS OUTPUT OddsRatios=outa&i.b&j; : proc logistic data=one desc; : model iiq1=a&i b&j age; : run; : ODS OUTPUT CLOSE; : %end; : %end;
| s******1 发帖数: 178 | 4 Sorry, I have another question. We still have the variables a1-a10 and b1-
b10 and I want to get another variable using all the combinations of a and b
, such as mix1=a1*b1, mix2=a1*b2, etc. There should be 100 combinations
totally. How should I do?
Thank you sooooo much!
【在 k*******a 的大作中提到】 : 可以用循环啊,比如 : %do i=1 %to 10; : %do j=1 %to 10; : ODS OUTPUT OddsRatios=outa&i.b&j; : proc logistic data=one desc; : model iiq1=a&i b&j age; : run; : ODS OUTPUT CLOSE; : %end; : %end;
| j******o 发帖数: 127 | 5 还是用循环。
*------------------------------------;
%macro mix();
%do i=1 %to 10;
%do j=1 %to 10;
a&i*b&j as mix_a&i._b&j
%if &i^=10 or &j^=10 %then ,;
%end;
%end;
%mend mix;
proc sql;
create table two as
select *, %mix()
from one;
quit;
*------------------------------------; | s******1 发帖数: 178 | |
|