View of FINAL.SAS (for PC23)


/* ------------------------------------------------------------------   */
/*  final.sas - FINAL PROJECT - modify this to do something interesting */
/* ------------------------------------------------------------------   */

%GLOBAL CHOICE;

/* for testing
%LET choice=a;
filename _webout 'c:\workshop\ws124\webout.htm';
end testing*/



options mprint;

           /* ---------------------------- */
           /* make a test dataset          */
           /* ---------------------------- */

data test;
do x=1 to 5;
 do y=1 to 3;
   z=x*y;
   w=round(1000*rannor(1213131),.1);
   output;
 end;
end;

run;
           /* ----------------------------------------------- */
           /* the first choice displays the dataset two ways: */
           /*  1. captures the output window (PROC PRINT)     */
           /*  2. with the ds2htm HTML formatting tool        */
           /* ----------------------------------------------- */
%MACRO CHOICEA;
 
title 'My final project -  Choice A - list the dataset examples ';

 %OUT2HTM(capture=on, window=output );
    proc print data=test; 
    run;
 %OUT2HTM(htmlfref=_webout,
             capture=off,
             window=output,
             runmode=s,
             bgtype=color,            /*background type               */
             ctext=#0000AA,             /* default text #rrggbb (HEX) */
             bg=#f3f7ff,                /*background                  */
             tcolor=#FF0000;            /*title                       */
             openmode=replace);

          /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  */
 
 %DS2HTM(data=test,
          runmode=b,
          openmode=append,
          htmlfref=_webout,
          caption=this is the TEST dataset,
          tcolor=#AA0000,              /* title                        */
          obsnum=Y,                    /* observation numbers          */
          obgcolr=#AAAAAA,             /* obs. num.  background color  */
          ocolor=#000000,              /* obs. num.  text color        */
          ccolor=blue,                 /* caption color                */
          clbgcolr=#AAAAAA,            /* column head background color */
          clcolor=#000000,             /* column label text color      */
          tbbgcolr=cyan);              /* table background color       */

%MEND CHOICEA;

           /* ------------------------------------------------------------- */
           /* the second choice uses the "tabulate to HTML" formatting tool */
           /* ------------------------------------------------------------- */
%MACRO CHOICEB;
title 'My final project -  choice B PROC Tabulate example ';

  %TAB2HTM(capture=on);

    options linesize=96 pagesize=54 nocenter nodate nonumber;

    title 'Example: Tabulated TEST dataset';
    proc tabulate data=WORK.TEST  formchar='82838485868788898a8b8c'x;                                               
     table Y   ALL                                                              
        ,(Z W ) * ( 'MEAN' 'STD')                                                                                                                             
        ;                                                                       
     var Z W ;                                                                  
     class Y ;                                                                  
    run;            

  %TAB2HTM(capture=off, 
          runmode=s,
          openmode=replace,
          htmlfref=_webout,
          brtitle=tabulated TEST dataset,
          clbgcolr=#EEEEEE,            /* column head background color */
          clcolor=#000000,             /* column label text color      */
          rlbgcolr=#EEEEEE,            /* row head background color    */
          rlcolor=#000000,             /* row label text color         */
          bxbgcolr=#AAAAAA,            /* box cell background color    */
          bxcolor=#000000,             /* box cell text color         */
          center=Y);


%MEND CHOICEB;

           /* ---------------------------------------- */
           /* this prints out an error message         */
           /* ---------------------------------------- */
%MACRO OOPS;
title 'Your Error Message:';
  data _null_;
   file _webout;
   pick=symget('CHOICE');
   put 'Content-type: text/html'// 'Unknown choice:'/ pick;
  run;
%MEND OOPS;

           /* ----------------------------------------------------- */
           /* code selection is done in macro PICKONE which invokes */
           /* either the macro "CHOICEA" or "CHOICEB" or "OOPS"     */
           /* ----------------------------------------------------- */

%MACRO PICKONE;

%IF %upcase(%superq(CHOICE))=A %THEN %DO ;
  %CHOICEA;
%END;
%ELSE %IF %upcase(%superq(CHOICE))=B %THEN %DO;
  %CHOICEB;
%END;
%ELSE %DO;
  %OOPS;
%END;


%MEND PICKONE;
%PICKONE;

 

   

back to the overview