boxplot_test.sas

Go to the documentation of this file.
00001  
00019 /* History
00020    05.10.2010 AM  Changed output format to pdf in order to be able to run on linux
00021 */ 
00022 
00023 /*-- standard case without reference -----------------------------------------*/
00024 %initTestcase(i_object=boxplot.sas, i_desc=standard case without reference)
00025 %boxplot(data=testdata.blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report1.pdf)
00026 %assertReport(i_actual=&g_work\report1.pdf, i_expected=,
00027               i_desc=please compare chart with specification in source code)
00028 
00029 /*-- standard case with reference --------------------------------------------*/
00030 %initTestcase(i_object=boxplot.sas, i_desc=standard case with reference)
00031 %boxplot(data=testdata.blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report2.pdf)
00032 %assertReport(i_actual=&g_work\report2.pdf, i_expected=&g_refdata\boxplot1.pdf,
00033               i_desc=please compare the two charts)
00034 
00035 /*-- standard case with reference, missing values for Y ----------------------*/
00036 %initTestcase(i_object=boxplot.sas, i_desc=%str(standard case with reference, missing values for Y ))
00037 data blood_pressure; 
00038    set testdata.blood_pressure; 
00039    output; 
00040    sbp=.;
00041    output;
00042 run; 
00043 %boxplot(data=blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report3.pdf)
00044 %assertReport(i_actual=&g_work\report3.pdf, i_expected=&g_refdata\boxplot1.pdf,
00045               i_desc=%str(please compare the two charts, no changes produced by missing values in the y variable))
00046 %assertLogMsg(i_logMsg=%str(NOTE: 240 observation\(s\) contained a MISSING value for the SBP \* Visit = Med request))
00047 
00048 /*-- different scaling for x and y axis --------------------------------------*/
00049 %initTestcase(i_object=boxplot.sas, i_desc=different scaling for x and y axis)
00050 data blood_pressure; 
00051    set testdata.blood_pressure; 
00052    visit=visit*100; 
00053    sbp=sbp*100;
00054 run; 
00055 %boxplot(data=blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report4.pdf)
00056 %assertReport(i_actual=&g_work\report4.pdf, i_expected=,
00057               i_desc=please compare chart with specification in source code)
00058 
00059 /*-- only two visits ---------------------------------------------------------*/
00060 %initTestcase(i_object=boxplot.sas, i_desc=only two visits)
00061 data blood_pressure; 
00062    set testdata.blood_pressure; 
00063    where visit in (1, 5);
00064 run; 
00065 %boxplot(data=blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report5.pdf)
00066 %assertReport(i_actual=&g_work\report5.pdf, i_expected=,
00067               i_desc=please compare chart with specification in source code)
00068 
00069 /*-- Error: only one visit ---------------------------------------------------*/
00070 %initTestcase(i_object=boxplot.sas, i_desc=only one visit)
00071 data blood_pressure; 
00072    set testdata.blood_pressure; 
00073    where visit in (3);
00074 run; 
00075 %boxplot(data=blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report6.pdf)
00076 %assertLogMsg(i_logMsg=ERROR: boxplot: x variable must have at least two values)
00077 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report6.pdf)), i_expected=0, i_desc=no report created)
00078 %endTestcase(i_assertLog=0)
00079 
00080 /*-- 18 visits ---------------------------------------------------------------*/
00081 %initTestcase(i_object=boxplot.sas, i_desc=18 visits)
00082 data blood_pressure; 
00083    set 
00084       testdata.blood_pressure (in=in1)
00085       testdata.blood_pressure (in=in2)
00086       testdata.blood_pressure (in=in3)
00087    ; 
00088    if in2 then visit=visit+6;
00089    if in3 then visit=visit+12;
00090 run; 
00091 %boxplot(data=blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report7.pdf)
00092 %assertReport(i_actual=&g_work\report7.pdf, i_expected=,
00093               i_desc=please compare chart with specification in source code)
00094 
00095 /*-- Error: invalid input data set -------------------------------------------*/
00096 %initTestcase(i_object=boxplot.sas, i_desc=invalid input data set)
00097 %boxplot(data=XXXXX, x=visit, y=sbp, group=med, report=&g_work\report8.pdf)
00098 %assertLogMsg(i_logMsg=ERROR: boxplot: Data set XXXXX does not exist)
00099 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report8.pdf)), i_expected=0, i_desc=no report created)
00100 %endTestcase(i_assertLog=0)
00101 
00102 /*-- Error: input data set missing -------------------------------------------*/
00103 %initTestcase(i_object=boxplot.sas, i_desc=input data set missing)
00104 %boxplot(data=, x=visit, y=sbp, group=med, report=&g_work\report9.pdf)
00105 %assertLogMsg(i_logMsg=ERROR: boxplot: Data set does not exist)
00106 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report9.pdf)), i_expected=0, i_desc=no report created)
00107 %endTestcase(i_assertLog=0)
00108 
00109 /*-- Error: invalid x variable -----------------------------------------------*/
00110 %initTestcase(i_object=boxplot.sas, i_desc=invalid x variable)
00111 %boxplot(data=testdata.blood_pressure, x=visitXXX, y=sbp, group=med, report=&g_work\report10.pdf)
00112 %assertLogMsg(i_logMsg=ERROR: boxplot: Variable visitXXX does not exist in data set testdata.blood_pressure)
00113 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report10.pdf)), i_expected=0, i_desc=no report created)
00114 %endTestcase(i_assertLog=0)
00115 
00116 /*-- Error: x variable missing -----------------------------------------------*/
00117 %initTestcase(i_object=boxplot.sas, i_desc=x variable missing)
00118 %boxplot(data=testdata.blood_pressure, x=, y=sbp, group=med, report=&g_work\report11.pdf)
00119 %assertLogMsg(i_logMsg=ERROR: boxplot: X variable not specified)
00120 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report11.pdf)), i_expected=0, i_desc=no report created)
00121 %endTestcase(i_assertLog=0)
00122 
00123 /*-- Error: x variable not numeric -------------------------------------------*/
00124 %initTestcase(i_object=boxplot.sas, i_desc=x variable not numeric)
00125 data blood_pressure;
00126    set testdata.blood_pressure; 
00127    visitc = put (visit, 1.);
00128 run; 
00129 %boxplot(data=blood_pressure, x=visitc, y=sbp, group=med, report=&g_work\report12.pdf)
00130 %assertLogMsg(i_logMsg=ERROR: boxplot: Variable visitc in data set blood_pressure must be numeric)
00131 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report12.pdf)), i_expected=0, i_desc=no report created)
00132 %endTestcase(i_assertLog=0)
00133 
00134 /*-- Error: x variable values not equidistant --------------------------------*/
00135 %initTestcase(i_object=boxplot.sas, i_desc=x variable values not equidistant)
00136 data blood_pressure;
00137    set testdata.blood_pressure; 
00138    if visit=5 then visit=6;
00139 run; 
00140 %boxplot(data=blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report13.pdf)
00141 %assertLogMsg(i_logMsg=ERROR: boxplot: Values of x variable are not equidistant)
00142 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report13.pdf)), i_expected=0, i_desc=no report created)
00143 %endTestcase(i_assertLog=0)
00144 
00145 /*-- Error: x variable has missing values ------------------------------------*/
00146 %initTestcase(i_object=boxplot.sas, i_desc=x variable has missing values)
00147 data blood_pressure;
00148    set testdata.blood_pressure; 
00149    output; 
00150    visit=.; 
00151    output; 
00152 run; 
00153 %boxplot(data=blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report14.pdf)
00154 %assertLogMsg(i_logMsg=ERROR: boxplot: Missing values in x variable are not allowed)
00155 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report14.pdf)), i_expected=0, i_desc=no report created)
00156 %endTestcase(i_assertLog=0)
00157 
00158 /*-- Error: invalid y variable -----------------------------------------------*/
00159 %initTestcase(i_object=boxplot.sas, i_desc=invalid y variable)
00160 %boxplot(data=testdata.blood_pressure, x=visit, y=sbpXXX, group=med, report=&g_work\report15.pdf)
00161 %assertLogMsg(i_logMsg=ERROR: boxplot: Variable sbpXXX does not exist in data set testdata.blood_pressure)
00162 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report15.pdf)), i_expected=0, i_desc=no report created)
00163 %endTestcase(i_assertLog=0)
00164 
00165 /*-- Error: y variable not specified -----------------------------------------*/
00166 %initTestcase(i_object=boxplot.sas, i_desc=y variable not specified)
00167 %boxplot(data=testdata.blood_pressure, x=visit, y=, group=med, report=&g_work\report16.pdf)
00168 %assertLogMsg(i_logMsg=ERROR: boxplot: Y variable not specified)
00169 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report16.pdf)), i_expected=0, i_desc=no report created)
00170 %endTestcase(i_assertLog=0)
00171 
00172 /*-- Error: y variable not numeric -------------------------------------------*/
00173 %initTestcase(i_object=boxplot.sas, i_desc=y variable not numeric)
00174 data blood_pressure;
00175    set testdata.blood_pressure; 
00176    sbpc = put (sbp, best32.);
00177 run; 
00178 %boxplot(data=blood_pressure, x=visit, y=sbpc, group=med, report=&g_work\report17.pdf)
00179 %assertLogMsg(i_logMsg=ERROR: boxplot: Variable sbpc in data set blood_pressure must be numeric)
00180 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report17.pdf)), i_expected=0, i_desc=no report created)
00181 %endTestcase(i_assertLog=0)
00182 
00183 /*-- Error: invalid group variable -------------------------------------------*/
00184 %initTestcase(i_object=boxplot.sas, i_desc=invalid group variable)
00185 %boxplot(data=testdata.blood_pressure, x=visit, y=sbp, group=medXXX, report=&g_work\report18.pdf)
00186 %assertLogMsg(i_logMsg=ERROR: boxplot: Variable medXXX does not exist in data set testdata.blood_pressure)
00187 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report18.pdf)), i_expected=0, i_desc=no report created)
00188 %endTestcase(i_assertLog=0)
00189 
00190 /*-- Error: group variable not specified -------------------------------------*/
00191 %initTestcase(i_object=boxplot.sas, i_desc=group variable not specified)
00192 %boxplot(data=testdata.blood_pressure, x=visit, y=sbp, group=, report=&g_work\report19.pdf)
00193 %assertLogMsg(i_logMsg=ERROR: boxplot: Group variable not specified)
00194 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report19.pdf)), i_expected=0, i_desc=no report created)
00195 %endTestcase(i_assertLog=0)
00196 
00197 /*-- Error: group variable has only one value --------------------------------*/
00198 %initTestcase(i_object=boxplot.sas, i_desc=group variable has only one value)
00199 data blood_pressure;
00200    set testdata.blood_pressure; 
00201    if med=1; 
00202 run; 
00203 %boxplot(data=blood_pressure, x=visit, y=sbp, group=med, report=&g_work\report20.pdf)
00204 %assertLogMsg(i_logMsg=ERROR: boxplot: Variable med must have exactly two values)
00205 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report20.pdf)), i_expected=0, i_desc=no report created)
00206 %endTestcase(i_assertLog=0)
00207 
00208 /*-- Error: group variable has more than two values -------------------------*/
00209 %initTestcase(i_object=boxplot.sas, i_desc=group variable has more than two values)
00210 data blood_pressure2;
00211    set testdata.blood_pressure; 
00212    if med=1 then do; 
00213       output; 
00214       med=2; 
00215       output; 
00216    end;  
00217    else output;
00218 run; 
00219 %boxplot(data=blood_pressure2, x=visit, y=sbp, group=med, report=&g_work\report21.pdf)
00220 %assertLogMsg(i_logMsg=ERROR: boxplot: Variable med must have exactly two values)
00221 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report21.pdf)), i_expected=0, i_desc=no report created)
00222 %endTestcase(i_assertLog=0)
00223 
00224 /*-- Error: group variable has missing values --------------------------------*/
00225 %initTestcase(i_object=boxplot.sas, i_desc=group variable has missing values)
00226 data blood_pressure3;
00227    set testdata.blood_pressure; 
00228    if med=0 then do; 
00229       med=.; 
00230       output; 
00231    end;  
00232 run; 
00233 %boxplot(data=blood_pressure3, x=visit, y=sbp, group=med, report=&g_work\report22.pdf)
00234 %assertLogMsg(i_logMsg=ERROR: boxplot: Missing values in group variable are not allowed)
00235 %assertEquals(i_actual=%sysfunc(fileexist(&g_work\report22.pdf)), i_expected=0, i_desc=no report created)
00236 %endTestcase(i_assertLog=0)
00237 

Generated on Sun Oct 10 14:10:15 2010 for SASUnit Examples by  doxygen 1.5.3