w*****1 发帖数: 473 | 1 【 以下文字转载自 Statistics 讨论区 】
发信人: wz99331 (dotti), 信区: Statistics
标 题: a question about SAS
发信站: BBS 未名空间站 (Mon Apr 2 12:52:18 2012, 美东)
我需要用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 w... 阅读全帖 |
|
w*****1 发帖数: 473 | 2 【 以下文字转载自 Statistics 讨论区 】
发信人: wz99331 (dotti), 信区: Statistics
标 题: a question about SAS
发信站: BBS 未名空间站 (Mon Apr 2 12:52:18 2012, 美东)
我需要用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 w... 阅读全帖 |
|
l*********t 发帖数: 18 | 3 我写了一个很短的macro, 用来提取sas dataset的attribute.
%macro getattrn(indata=, attrn=);
%if %sysfunc(exist(&indata)) %then %do;
%* open data set;
%let did=%sysfunc(open(&indata));
%* Get attribute;
%let attvalue=%sysfunc(attrn(&did, &attrn));
%* Close data set;
%sysfunc(close(&did));
%end;
%else %let attvalue=-999;
&attvalue
%mend getattrn;
然后call的时候就把值赋给一个marco variable, 比如
%let MV=%getattrn(indata=mydata, attrn=nobs)
按道理这个macro应该返回mydata里面的observation个数. 但是我查MV的值竟然是:
0; 396... 阅读全帖 |
|
w*****1 发帖数: 473 | 4 我需要用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;
... 阅读全帖 |
|
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)*... 阅读全帖 |
|
f**o 发帖数: 12685 | 6 c#
using System.IO;
using System.IO.Ports;
using System.Threading;
namespace RS232RVR
{
public partial class Form1 : Form
{
private delegate void SetTextDeleg(string data);
public Form1()
{
InitializeComponent();
SettingRS232();
}
public void SettingRS232 ()
{
try
{
SerialPort mySerialPort = new SerialPort("COM6");
mySerialPort.BaudRate = 9600;
m... 阅读全帖 |
|
A*********u 发帖数: 8976 | 7 proc sort data=indata out=uniqueid(keep=id) nodupkey;
by id;
run;
data shell;
set uniqueid;
do x=2002 to 2008;
output;
end;
run;
** sort indata and shell by id x;
data temp;
merge indata shell;
by id x;
retain IND_;
if first.id then do;
ind_=0;
end;
if y=0 then do;
IND=1;
ind_=1;
end;
if y=. then do;
if ind_=0 then ind=0;
if ind_=1 then ind=1;
end;
if y=1 then do;
ind=1;
ind_=0 |
|
s*****r 发帖数: 790 | 8 because the variables maybe either numeric or non-numeric, you may consider
first create auxiliary numeric variables using the function missing. then
use proc means on all the auxiliary variables.
you can write a macro to do it automatically. something like:
%macro missing(indata, outdata);
proc contents data=indata out=_tmp;
run;
proc sql;
select name into: _name_list
from _tmp;
quit;
data _t1;
set indata;
%do loop for each variable in _name_list;
var_aux=missing(var);
run;
proc means data=... 阅读全帖 |
|
s********p 发帖数: 637 | 9 %let outvar=;
%macro cal_var_nums(indata);
proc contents data=&indata out=out noprint; run;
proc sql noprint;
select count(name) into :outvar
from out
;
quit;
%mend;
%cal_var_nums(model(obs=0));
%put "Total variable:" &outvar;
%cal_var_nums(model(obs=0 keep=_NUMERIC_ ));
%put "Num variable:" &outvar;
%cal_var_nums(model(obs=0 keep=_CHARACTER_ ));
%put "Char variable:" &outvar; |
|
k*****n 发帖数: 361 | 10 想用macro输出结果到一个excel多tab上,但是一直出错说EG是32bit,2010是64bit,
google了也没好办法,code如下
%macro exportexcel(indata,sheetnm);
proc export data= &indata
outfile="\la.comaddgroupincmdm.xlsx"
DBMS=XLSX REPLACE;
SHEET="&sheetnm";
newfile=yes;
VERSION=2010;
run;
%mend;
%exportexcel(myfile_d.AddGroupNOTInCMDM,Sheet1);
%exportexcel(myfile_d.AddGroupInCMDM,Sheet2); |
|
b******a 发帖数: 215 | 11 用proc download从远程server下载
很简单的proc
proc download in=indata out=outdata mt=(data cat);
前面几个catory的文件都下载的正常,但是突然就报错:
ERROR: Domain error.
远程文件里面就有data 和cat两种类型。
谢谢。
请问会有什么方面的问题呢? |
|
g****8 发帖数: 2828 | 12 %new(mudaa=&mudaa, mudab=&mudab, mudbb=&mudbb, de=&de, dq=&dq,
indata=grid, outdata=gridsearch);
这些variable都没有在macro外面定义,你怎么用呀? |
|