%put NOTE: You have called the macro _DEBUGS, 2007-10-24; %put NOTE: Copyright (c) 2001-2007 Rodney Sparapani; %put; /* Author: Rodney Sparapani Created: 2007-10-10 This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this file; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. In short: you may use this file any way you like, as long as you don't charge money for it, remove this notice, or hold anyone liable for its results. */ /* _DEBUGS Documentation Reads a SAS dataset and provides summaries as requested. REQUIRED Parameters DATA=REQUIRED SAS input dataset VAR=REQUIRED list of variables to summarize/graph use _all_ for all Specific OPTIONAL Parameters AUTOCORR=0 auto-correlation statistics are not calculated unless AUTOCORR=1 or NLAG NE 25 (SAS/ETS required) CHAIN=CHAIN default name of chain variable, set to blank for none GRAPHICS=1 if statistics are requested, then produce graphics as well (v. 8 or higher only) GSFMODE=REPLACE default GSFMODE for first graph ITER=ITER default name of iteration variable, set to blank for none MU0=0 default location for tests/tables NLAG=25 default of up to 25 lag auto-correlation if AUTOCORR=1 OBS=OBS default name of obs variable, set to blank for none OPTIONS= options to PROC UNIVARIATE PCTLDEF=5 default percentile definition PCTLPTS=2.5 97.5 default percentiles to calcuate and present SYMBOL=i=join v=none r=1 default SYMBOL statement for trace plots THIN=1 default thinning parameter, set to an integer >1 for only keeping iterations where MOD(ITER, THIN)=0 TRACE=1 default to produce trace plots TYPE= if you set this parameter, then TYPE will be used to name the graphics file (VAR.TYPE) for each summarized variable, currently useful only for scalar variables WEIGHT= default name of weight variable, set to blank for none WHERE= restrict the data with a WHERE clause, useful for removing burn-in, i.e. WHERE=iter>4000 Common OPTIONAL Parameters LOG= set to /dev/null to turn off .log */ %macro _debugs(data=REQUIRED, var=REQUIRED, autocorr=, chain=chain, graphics=%_version(8), iter=iter, gsfmode=replace, mu0=0, nlag=25, obs=obs, options=, pctldef=5, pctlpts=2.5 97.5, symbol=i=join v=none r=1, thin=1, trace=1, type=, weight=, where=, log=); %_require(&data &var); %if %length(&log) %then %_printto(log=&log); %local i j scratch; %let chain=%upcase(&chain); %let iter=%upcase(&iter); %let obs=%upcase(&obs); %let weight=%upcase(&weight); %let var=%upcase(%_blist(var=&var, data=&data, nofmt=1)); %if %_count(&pctlpts)=1 %then %let pctlpts=&pctlpts %sysevalf(100-&pctlpts); %let scratch=%_scratch; %let j=0; %do i=1 %to %_count(&var); %local var&i; %let var&i=%scan(&var, &i, %str( )); %if "&&var&i"^="&obs" & "&&var&i"^="&chain" & "&&var&i"^="&iter" & "&&var&i"^="&weight" %then %do; %let j=%eval(&j+1); %local where&j; %if %length(&where) %then %let where&j=&where & n(&&var&i); %else %let where&j=n(&&var&i); %if &thin>1 %then %let where&j=&&where&j & mod(&iter, &thin)=0; %if &graphics %then %do; %if %length(&type) %then filename gsasfile "&&var&i...&type";; %if &j=1 %then goptions gsfmode=&gsfmode; %else goptions gsfmode=append;; %end; proc univariate loccount modes mu0=&mu0 pctldef=&pctldef plot &options data=&data(keep=&obs &chain &iter &&var&i where=(&&where&j)); id &chain &iter; by &obs; var &&var&i; output out=&scratch pctlpre=&&var&i.._ pctlpts=&pctlpts; %if &graphics %then histogram &&var&i / kernel;; run; proc print; run; %if &graphics=1 & &trace=1 %then %do; %if &j=1 %then goptions gsfmode=append;; symbol1 &symbol; proc gplot data=&data(keep=&obs &chain &iter &&var&i where=(&&where&j)); by &obs; plot &&var&i*&iter=&chain; run; quit; %end; %if &autocorr=1 | &nlag^=25 %then %do; proc arima data=&data(keep=&obs &chain &iter &&var&i where=(&&where&j)); by &obs &chain; identify var=&&var&i nlag=&nlag; run; quit; %end; %end; %end; %if %length(&log) %then %_printto; %mend _debugs; %*VALIDATION TEST STREAM; /* un-comment to re-validate */