getvars_test.sas

Go to the documentation of this file.
00001  
00019 /*-- simple example with sashelp.class ---------------------------------------*/
00020 %initTestcase(i_object=getvars.sas, i_desc=simple example with sashelp.class)
00021 %let vars=%getvars(sashelp.class);
00022 /* %endTestcall() can be omitted, will called implicitly by the first assert */
00023 %assertEquals(i_actual=&vars, i_expected=Name Sex Age Height Weight, i_desc=Variablen prüfen)
00024 /* %endTestcase() can be omitted, will called implicitly by the next initTestcase */
00025 
00026 /*-- simple example with sashelp.class, different delimiter ------------------*/
00027 %initTestcase(i_object=getvars.sas, i_desc=%str(simple example with sashelp.class, different delimiter))
00028 %let vars=%getvars(sashelp.class,dlm=%str(,));
00029 %assertEquals(i_actual=&vars, i_expected=%str(Name,Sex,Age,Height,Weight), i_desc=check variables)
00030 
00031 /*-- example with variable names containing special characters ---------------*/
00032 %initTestcase(i_object=getvars.sas, i_desc=example with variable names containing special characters)
00033 options validvarname=any;
00034 data test; 
00035    'a b c'n=1; 
00036    '$6789'n=2;
00037    ';6789'n=2;
00038 run; 
00039 %let vars="%getvars(test,dlm=%str(","))";
00040 %assertEquals(i_actual=&vars, i_expected=%str("a b c","$6789",";6789"), i_desc=check variables)
00041 %macro al;
00042 %if &sysver=9.1 %then %do;
00043    %assertLog(i_warnings=1,i_desc=%str(check log, one warning due to validvarname))
00044    %endTestcase(i_assertLog=0) /* no assertLog */
00045 %end;
00046 %mend al;
00047 %al;
00048 
00049 /*-- example with empty dataset ----------------------------------------------*/
00050 %initTestcase(i_object=getvars.sas, i_desc=example with empty dataset)
00051 data test; 
00052    stop;
00053 run; 
00054 %let vars=%getvars(test);
00055 %assertEquals(i_actual=&vars, i_expected=, i_desc=no variables found)
00056 
00057 /*-- example without dataset specified ---------------------------------------*/
00058 %initTestcase(i_object=getvars.sas, i_desc=example without dataset specified)
00059 %let vars=%getvars();
00060 %assertEquals(i_actual=&vars, i_expected=, i_desc=no variables found)
00061 
00062 /*-- example with invalid dataset --------------------------------------------*/
00063 %initTestcase(i_object=getvars.sas, i_desc=example with invalid dataset)
00064 %let vars=%getvars(xxx);
00065 %assertEquals(i_actual=&vars, i_expected=, i_desc=example with invalid dataset)
00066 
00067 

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