View of IFFY.SAS



/* ---------------------------------------------------   */
/*  iffy.sas - select logic based on a form              */
/* ---------------------------------------------------   */

%global CHOICE;

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 uses the dataset to HTML formatting tool */
           /* --------------------------------------------------------- */
%macro CHOICEA;

  %ds2htm(data=test,
          runmode=s,
          openmode=replace,
          htmlfref=_webout,
          caption=this is the TEST dataset,
          ccolor=blue,
          tbbgcolr=cyan);

%mend CHOICEA;

           /* ----------------------------------------------------------- */
           /* the second choice uses the tabulate to HTML formatting tool */
           /* ----------------------------------------------------------- */
%macro CHOICEB;

  %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,
          center=Y);


%mend CHOICEB;

           /* ---------------------------------------- */
           /* this prints out an error message         */
           /* ---------------------------------------- */
%macro OOPS;
  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"               */
           /* ----------------------------------------------------- */

%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