00001 |
/** |
00002 |
\file |
00003 |
\ingroup SASUNIT_EXAMPLES_PGM |
00004 |
|
00005 |
\brief Linear regression analysis - example for SASUnit |
00006 |
|
00007 |
Calculate a simple linear regression with intercept for the two variables specified and |
00008 |
- write input data and estimated values to the output dataset &out |
00009 |
- write regression parameters to output dataset &parms |
00010 |
- generate a report in RTF format containing a plot of predicted and observed values |
00011 |
|
00012 |
This example contains no validation of macro parameters |
00013 |
|
00014 |
\version \$Revision: 315 $ |
00015 |
\author \$Author: klandwich $ |
00016 |
\date \$Date: 2014-02-28 10:25:18 +0100 (Fr, 28 Feb 2014) $ |
00017 |
\sa For further information please refer to SASUnit User's Guide |
00018 |
\sa \$HeadURL: https://svn.code.sf.net/p/sasunit/code/trunk/example/saspgm/regression.sas $ |
00019 |
\copyright Copyright 2010, 2012 HMS Analytical Software GmbH. |
00020 |
This file is part of SASUnit, the Unit testing framework for SAS(R) programs. |
00021 |
For terms of usage under the GPL license see included file readme.txt |
00022 |
or https://sourceforge.net/p/sasunit/wiki/readme.v1.2/. |
00023 |
|
00024 |
\param data input dataset |
00025 |
\param x variable for x axis, must be numeric |
00026 |
\param y variable for y axis, must be numeric |
00027 |
\param out output dataset, contains variables &x, &y and &yhat |
00028 |
\param yhat name of the variable with estimated values |
00029 |
\param parms output dataset with regression parameters |
00030 |
\param report report file (file extension must be .rtf) |
00031 |
*/ /** \cond */ |
00032 |
|
00033 |
%MACRO regression( |
00034 |
data = |
00035 |
,x = |
00036 |
,y = |
00037 |
,out = |
00038 |
,yhat = |
00039 |
,parms = |
00040 |
,report = |
00041 |
); |
00042 |
|
00043 |
%local dsid; |
00044 |
|
00045 |
ods _all_ close; |
00046 |
ods rtf file="&report"; |
00047 |
|
00048 |
/*-- Compute regression analysis ---------------------------------------------*/ |
00049 |
proc reg data=&data outest=&parms; |
00050 |
model &y = &x; |
00051 |
output out=&out(keep=&x &y &yhat) p=&yhat; |
00052 |
plot &y * &x; |
00053 |
run; quit; |
00054 |
|
00055 |
ods rtf close; |
00056 |
|
00057 |
%MEND regression; |
00058 |
|
00059 |
/** \endcond */ |