/* APR-sub.sas Daniel Brockman 070422 Macros for proj APR-proj-a1.sas */ /*--------------------------------------------------------- */ /*--------------------------------------------------------- */ /* * 2. Run PROC UNIVARIATE step for variable X1-X5, with ODS * trace on. */ %macro uvods(inp,varlist); /* inp is input data set varlist is list of variables delimited by spaces uvods runs proc univariate on the variables in the list with ods trace on Example: %uvods(mylib.myset,alpha beta gamma); */ ods trace on / listing; proc univariate data=&inp /*noprint*/ ; /* ods trace doesn't work with noprint */ var &varlist ; run; ods trace off; %mend uvods; /*--------------------------------------------------------- */ %macro printODSunivariate(inp,varlist); /* Some kind of bug in this macro occurs at proc print */ /* * Create and * print the ODS tables for proc univariate for the specified variables. * inp is the input data set which contains the variables named in var*. * varlist is the list of variable names, delimited by spaces. * Data sets created have names beginning with "univ_". * printODSunivariate uses proc print . * Example: * %printODSunivariate(myset,Wt Ht Dt Tm sys dia pul); */ %put "begin printODSunivariate ---inp:&inp varlist:&varlist " ; /* test */ %local list i j tab1 tab2 tab3 tab4 tab5 tab6 varj tabi odsset; %let tab1 = Moments; %let tab2 = BasicMeasures; %let tab3 = TestsForLocation; %let tab4 = Quantiles; %let tab5 = ExtremeObs; %let tab6 = MissingValues; %do j = 1 %to 10; /* variable loop */ %let varj = &&var&j; %if ( %length(&varj) ne 0 ) %then %do ; /* if varj exists */ /* * 3. Use PROC PRINT to print out various Tables captured by * ODS. */ %let list = ; /* make list */ %do i = 1 %to 6 ; %let list = %trim( &list &&tab&i ); %end ; /* i */ %put Before ods output select '&list.' list:&list. ; /* test */ ods output select &list. ; %put After ods output select '&list.' list:&list. ; /* test */ %do i = 1 %to 6 ; /* path loop */ %let tabi = &&tab&i ; %let odsset = Univariate_&varj._&tabi ; %put "i: &i j: &j varj: &varj tabi: &tabi"; /* test */ %put ods output Univariate.&varj..&tabi=&odsset ; /* test */ /* ods output Univariate.&varj..&tabi=&mylib..&varj._&tabi ; */ /* ods output Univariate.&varj..&tabi=&varj._&tabi ; */ /* ods output &tabi=univ_&varj._&tabi ; */ /* ods output &tabi=&tabi */ ; /* ods output &odsset=Univariate.&varj..&tabi ; */ ods output Univariate.&varj..&tabi=&odsset ; %put "before proc print " ; /*test*/ title "proc print data=&odsset i:&i j:&j varj:&varj tabi:&tabi." ; proc print data=&odsset. ; run; %put "after proc print " ; /*test*/ %end ; /* i */ %end; /* if &varj */ %end ; /* j */ %put "end printODSunivariate ---------- " ; /* test */ %mend printODSunivariate ; /*--------------------------------------------------------- */ /*--------------------------------------------------------- */ /*--------------------------------------------------------- */ /*--------------------------------------------------------- */ /*--------------------------------------------------------- */ /*--------------------------------------------------------- */