由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - a question about SAS
相关主题
请帮忙看3道SAS题。Need advice on SAS macro debugging
SAS help[合集] 一个sas问题
一道ADV 130 题目问个SAS题目,
请问SAS advanced macro global 和localkilltest Q78 79 80
SAS ADVANCED 一道题求助请教一个macro的问题
求助,SAS ADV 130 中94sas macro 问题,
proc iml help!SAS call symput question
一个常见的问题请问SAS ADV 130中74 和80题
相关话题的讨论汇总
话题: mudaa话题: mudbb话题: dq话题: mudab话题: de
进入Statistics版参与讨论
1 (共1页)
w*****1
发帖数: 473
1
我需要用MACRO 语言,用DO LOOP 改变一个模版的5个固定参数创建一些新的DATA,检
测这些新的DATA最大似然值.下面是我的CODE, 但是不能运行,大家能否帮我看看?包子
酬谢!
data parents; set csgl.individs;
keep i QTP pedid dgeno;
if i <=2;
run;
/* Do loops for grid search */
/*Y=g+R(mixed model), where g=Major Gene(latent fixed effect)with 3
values: mudaa, mudab, mudbb and R = Residual(variance component)*/
/*the max, min, and std will be used as grid search ranges */
%macro loops;
proc means data=parents;
var QTP;
output out=range min=min max=max std=std mean=mean;
run;
proc print data=range;
run;
data temp; set range;
%do e=1 %to 10;
de=e*std/10;
%do q=1 %to 10;
dq=(q-1)*0.1;
%do i=1 %to 21;
mudaa=min+(i-1)*(max-min)/20;
%do j=1 %to 21;
mudab=min+(j-1)*(max-min)/20;
%do k=1 %to 21;
mudbb=min+(k-1)*(max-min)/20;
output;
data _NULL_;
set two;
call symput("mudaa", mudaa);
call symput("mudab", mubab);
call symput("mudbb", mudbb);
call symput("de", de);
call symput("dq", dq);
run;
%put mudaa=&mudaa mudab=&mudab mudbb=&mudbb de=&de dq=&dq;
%end;
%end;
%end;
%end;
%end;
run;
%mend;
%loops;
%macro new(mudaa=, mudab=, mudbb=, de=, dq=, indata=, outdata=);
data &outdata; set &indata;
lnl=log((((1-&dq)**2)*(1/sqrt(2*constant('PI')*&de))*exp(-0.5*(((QTP-mudaa)/
&de)**2))+
2*&dq*(1-&dq)*(1/sqrt(2*constant('PI')*&de))*exp(-0.5*(((QTP-mudaa)/&
de)**2))+
(&dq**2)*(1/sqrt(2*constant('PI')*&de))*exp(-0.5*(((QTP-mudaa)/&de)**2
))));
run;
proc means data=&outdata sum;
var lnl;
output out=lnnew sum=sum;
run;
%mend new;
%new(mudaa=-0.6, mudab=0.0, mudbb=0.8, de=0.1, dq=0.4,
indata=parents, outdata=Sgridsearch);
%new(mudaa=&mudaa, mudab=&mudab, mudbb=&mudbb, de=&de, dq=&dq,
indata=temp, outdata=gridsearch);
proc sort data=gridsearch;
by descending lnlikelihood;
output out=grid_sort_search;
data grid_search; set grid_sort_search;
if(_N_ =1);
proc print data=grid_search noobs;
g****8
发帖数: 2828
2
error是什么?
w*******n
发帖数: 469
3
all macro variables need to put percent sign prior to the variables.
B****k
发帖数: 188
4
Data step 不能嵌套吧。
w*****1
发帖数: 473
5
Thank you very much for your help!
我改了CODE如下: 现在已运行了1小时还没有停止,大家能否帮我看看? 谢谢!
data parents; set csgl.individs;
keep i QTP pedid dgeno;
if i <=2;
run;
option symbolgen mprint mlogic;
%macro new(mudaa=, mudab=, mudbb=, de=, dq=, indata=, outdata=);
data &outdata; set &indata;
lnl=log(((1-&dq)**2)*(1/sqrt(2*constant('PI'))*&de)*exp(-0.5*(((QTP-&mudaa)/
&de)**2))+
2*&dq*(1-&dq)*(1/sqrt(2*constant('PI'))*&de)*exp(-0.5*(((QTP-&mudaa)/
&de)**2))+
(&dq**2)*(1/sqrt(2*constant('PI'))*&de)*exp(-0.5*(((QTP-&mudaa)/
&de)**2)));
run;
proc means data=&outdata sum;
var lnl;
output out=lnlike sum=sumlike;
run;
proc print data=grid;
title "my grid";
run;
%mend;
%new(mudaa=-0.6, mudab=0.0, mudbb=0.8, de=0.1, dq=0.4,
indata=parents, outdata=Sgridsearch);
%new(mudaa=&mudaa, mudab=&mudab, mudbb=&mudbb, de=&de, dq=&dq,
indata=grid, outdata=gridsearch);
proc sort data=gridsearch;
by descending sumlike;
output out=grid_sort_search;
data grid_search; set grid_sort_search;
if(_N_ =1);
proc print data=grid_search noobs;
run;
data _NULL_;
set range;
call symput("min", min);
call symput("max", max);
call symput("std", std);
run;
data grid;
%do e=1 %to 10;
%do q=1 %to 10;
%do i=1 %to 21;
%do j=1 %to 21;
%do k=1 %to 21;
de=%sysevalf(&e*&std / 10);
dq=%sysevalf((&q-1)*0.1);
mudaa=%sysevalf(&min+(&i-1)*(&max - &min)/20);
mudab=%sysevalf(&min+(&j-1)*(&max - &min)/20);
mudbb=%sysevalf(&min+(&k-1)*(&max - &min)/20);
output;
%end;
%end;
%end;
%end;
%end;
run;
/* Do loops for grid search */
/*Y=g+R(mixed model), where g=Major Gene(latent fixed effect)with 3
values: mudaa, mudab, mudbb and R = Residual(variance component)*/
/*the max, min, and std will be used as grid search ranges */
proc means data=parents;
var QTP;
output out=range min=min max=max std=std mean=mean;
run;
proc print data=range;
run;
g****8
发帖数: 2828
6
%new(mudaa=&mudaa, mudab=&mudab, mudbb=&mudbb, de=&de, dq=&dq,
indata=grid, outdata=gridsearch);
这些variable都没有在macro外面定义,你怎么用呀?
g****8
发帖数: 2828
7
前面那个macro还写得好点,大概就是macro variable引用的不对。
后面这个错了很多,楼主你是不是贴错code了。
1 (共1页)
进入Statistics版参与讨论
相关主题
请问SAS ADV 130中74 和80题SAS ADVANCED 一道题求助
【包子】求问个简单sas macro问题求助,SAS ADV 130 中94
请教SAS adv 题库一道macro题proc iml help!
sas题目恳请前辈指点!!一个常见的问题
请帮忙看3道SAS题。Need advice on SAS macro debugging
SAS help[合集] 一个sas问题
一道ADV 130 题目问个SAS题目,
请问SAS advanced macro global 和localkilltest Q78 79 80
相关话题的讨论汇总
话题: mudaa话题: mudbb话题: dq话题: mudab话题: de