📄 runmod.sas
字号:
if (_vname_ eq 'INTERCEP') then _vname_ = 'Intercept';
%end;
if (_vname_ not in('_LNLIKE_', '_SHAPE1_')) then do;
if (_vname_ eq 'Intercept' or _keep_) then put _vname_ $32. x(_i_) rb&ldouble..;
else _keep_ = 1;
end;
end;
end;
%if (&stratum eq ) %then %do; /* write covariances */
else if (_TYPE_ eq 'COV') then do;
_keep_ = 0;
do _i_ = 1 to dim(x);
call vname(x(_i_), _vname_);
%if (&sysver eq 6.12) %then %do;
if (_vname_ eq 'INTERCEP') then _vname_ = 'Intercept';
%end;
if (_vname_ not in('_LNLIKE_', '_SHAPE1_')) then do;
if (_vname_ eq 'Intercept' or _keep_) then put x(_i_) rb&ldouble..;
else _keep_ = 1;
end;
end;
end;
%end;
if (_end_) then do; /* write no auxiliary parameters */
_xparms_ = 0;
put _xparms_ ib&lint..;
end;
run;
%if (&syserr ne 0) %then %let msg = Estimates file error;
%end;
%else %if (&procid eq MIXED) %then %do; /* proc mixed */
data _null_; /* write loglikelihood */
set like1;
if (index(upcase(Descr), 'LOG') > 0) then do;
file "&outfile" mod recfm=n;
Value = Value / -2;
put Value rb&ldouble..;
end;
run;
%if (&syserr ne 0) %then %let msg = Log likelihood file error;
%if (%bquote(&msg) eq ) %then %do; /* write parameter estimates */
data _null_;
length pname $ 200;
estfile = open("est1", "i");
if (estfile eq 0) then do;
call symput("msg", "Parameters file error");
stop;
end;
nobs = attrn(estfile, "nobs");
fvar = varnum(estfile, "Effect");
evar = varnum(estfile, "Estimate");
lvar = evar - 1;
if (nobs eq 0 or fvar eq 0 or lvar lt fvar or evar eq 0) then do;
call symput("msg", "Parameters file error");
stop;
end;
file "&outfile" mod recfm=n;
put nobs ib&lint..;
do while (fetch(estfile) eq 0);
pname = "";
do var = fvar to lvar;
if (vartype(estfile, var) eq 'C') then pname = trim(pname) || " " || left(getvarc(estfile, var));
else pname = trim(pname) || " " || left(getvarn(estfile, var));
end;
pname = trim(left(pname));
if (substr(pname, 1, 9) eq "Intercept") then pname = "Intercept";
est = getvarn(estfile, evar);
put pname $32. est rb&ldouble..;
end;
run;
%end;
%if (%bquote(&msg) eq and &stratum eq ) %then %do; /* write covariances */
data _null_;
set covb1;
array x(*) _numeric_;
file "&outfile" mod recfm=n;
_keep_ = 0;
do _i_ = 1 to dim(x);
if (vname(x(_i_)) eq 'Col1') then _keep_ = 1;
if (_keep_) then put x(_i_) rb&ldouble..;
end;
run;
%if (&syserr ne 0) %then %let msg = Covariances file error;
%end;
%if (%bquote(&msg) eq ) %then %do;
%if (%sysfunc(exist(covparms))) %then %do; /* write covariance parameter estimates */
data _null_;
length pname $ 200;
estfile = open("covparms", "i");
if (estfile eq 0) then do;
call symput("msg", "Covariance parameters file error");
stop;
end;
nobs = attrn(estfile, "nobs");
pvar = varnum(estfile, "CovParm");
evar = varnum(estfile, "Estimate");
if (nobs eq 0 or pvar eq 0 or evar eq 0) then do;
call symput("msg", "Estimates file error");
stop;
end;
file "&outfile" mod recfm=n;
put nobs ib&lint..;
do while (fetch(estfile) eq 0);
pname = getvarc(estfile, pvar);
pname = trim(left(pname));
est = getvarn(estfile, evar);
put pname $32. est rb&ldouble..;
end;
run;
%if (&syserr ne 0) %then %let msg = Covariance parameters file error;
%end;
%else %do; /* write no more auxiliary parameters */
data _null_;
file "&outfile" mod recfm=n;
_xparms_ = 0;
put _xparms_ ib&lint..;
run;
%end;
%end;
%end;
%else %if (&procid eq NLIN) %then %do; /* proc nlin */
data _null_;
set est1 end=_end_;
array x(*) _numeric_;
length _vname_ $ 32;
file "&outfile" mod recfm=n;
if (_n_ eq 1) then do; /* write loglikelihood */
_like_ = 0;
put _like_ rb&ldouble..;
end;
if (_TYPE_ eq 'FINAL') then do; /* write parameter estimates */
_coefs_ = 0;
do _i_ = 1 to dim(x);
call vname(x(_i_), _vname_);
if (_vname_ not in('_ITER_', '_SSE_')) then _coefs_ = _coefs_ + 1;
end;
put _coefs_ ib&lint..;
do _i_ = 1 to dim(x);
call vname(x(_i_), _vname_);
if (_vname_ not in('_ITER_', '_SSE_')) then put _vname_ $32. x(_i_) rb&ldouble..;
end;
end;
%if (&cluster eq ) %then %do; /* write covariances */
if (_TYPE_ eq 'COVB') then do _i_ = 1 to dim(x);
call vname(x(_i_), _vname_);
if (_vname_ not in('_ITER_', '_SSE_')) then put x(_i_) rb&ldouble..;
end;
%end;
if (_end_) then do; /* write no auxiliary parameters */
_xparms_ = 0;
put _xparms_ ib&lint..;
end;
run;
%if (&syserr ne 0) %then %let msg = Estimates file error;
%end;
%else %if (&procid eq PHREG) %then %do; /* proc phreg */
data _null_; /* write loglikelihood */
set like1;
where (index(upcase(Criterion), 'LOG') > 0);
file "&outfile" mod recfm=n;
WithCovariates = WithCovariates / -2;
put WithCovariates rb&ldouble..;
run;
%if (&syserr ne 0) %then %let msg = Log likelihood file error;
%if (%bquote(&msg) eq ) %then %do; /* write number of parameters */
data _null_;
estfile = open("est1", "i");
if (estfile eq 0) then do;
call symput("msg", "Parameters file error");
stop;
end;
nobs = attrn(estfile, "nobs");
if (nobs eq 0) then do;
call symput("msg", "Parameters file error");
stop;
end;
file "&outfile" mod recfm=n;
put nobs ib&lint..;
run;
%end;
%if (%bquote(&msg) eq ) %then %do; /* write parameter estimates */
data _null_;
set est1;
file "&outfile" mod recfm=n;
put Variable $32. Estimate rb&ldouble..;
run;
%end;
%if (%bquote(&msg) eq and &cluster eq ) %then %do; /* write covariances */
data _null_;
set covb1;
array x(*) _numeric_;
file "&outfile" mod recfm=n;
put (x(*)) (rb&ldouble..);
run;
%end;
%if (%bquote(&msg) eq ) %then %do; /* write no auxiliary parameters */
data _null_;
file "&outfile" mod recfm=n;
_xparms_ = 0;
put _xparms_ ib&lint..;
run;
%end;
%end;
%else %if (&procid eq PROBIT) %then %do; /* proc probit */
data _null_;
set est1 end=_end_;
array x(*) _numeric_;
length _vname_ $ 32;
file "&outfile" mod recfm=n;
if (_n_ eq 1) then do; /* write loglikelihood */
put _LNLIKE_ rb&ldouble..;
end;
if (_TYPE_ eq 'PARMS') then do; /* write parameter estimates */
_coefs_ = 0;
_keep_ = 0;
do _i_ = 1 to dim(x);
call vname(x(_i_), _vname_);
%if (&sysver eq 6.12) %then %do;
if (_vname_ eq 'INTERCEP') then _vname_ = 'Intercept';
%end;
if (_vname_ not in('_LNLIKE_', '_C_')) then do;
if (_vname_ eq 'Intercept' or _keep_) then _coefs_ = _coefs_ + 1;
else _keep_ = 1;
end;
end;
put _coefs_ ib&lint..;
_keep_ = 0;
do _i_ = 1 to dim(x);
call vname(x(_i_), _vname_);
%if (&sysver eq 6.12) %then %do;
if (_vname_ eq 'INTERCEP') then _vname_ = 'Intercept';
%end;
if (_vname_ not in('_LNLIKE_', '_C_')) then do;
if (_vname_ eq 'Intercept' or _keep_) then put _vname_ $32. x(_i_) rb&ldouble..;
else _keep_ = 1;
end;
end;
end;
%if (&cluster eq ) %then %do; /* write covariances */
if (_TYPE_ eq 'COV') then do;
_keep_ = 0;
do _i_ = 1 to dim(x);
call vname(x(_i_), _vname_);
%if (&sysver eq 6.12) %then %do;
if (_vname_ eq 'INTERCEP') then _vname_ = 'Intercept';
%end;
if (_vname_ not in('_LNLIKE_', '_C_')) then do;
if (_vname_ eq 'Intercept' or _keep_) then put x(_i_) rb&ldouble..;
else _keep_ = 1;
end;
end;
end;
%end;
if (_end_) then do; /* write no auxiliary parameters */
_xparms_ = 0;
put _xparms_ ib&lint..;
end;
run;
%end;
%end; /* end procedure error if */
%end; /* end previous error if */
%mend runmod;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -