MACRO ROW OUTV

Aus phenixxenia.org
Wechseln zu: Navigation, Suche

Zurück

Übersicht

Vorwärts

Type

Core module from Phase-III Macro System based on Fractal System Architecture.

Source

%MACRO ROW_OUTV(dsn=,head=Y,stat=Y,var=,pvalue=,nulltxt=N) / store des="Create Row of SuperCells for continuous variable";
%LOCAL name n_grp label n_lst v_lst i n rsrv_int;
%GLOBAL CURBY CURDSN CURCON CURMISS CURSTATS RECOFLAG;
%LET name=ROW_OUTV;
%LET rsrv_int=6;
%GEN_RECO(recode="N"="N with data" "Nmiss"="N missing" "Std"="SD" "Pvalue"="p-value (a)");
%GRP_DESC(dsn=&CURDSN,grp=&CURBY,miss=&CURMISS);
%GET_ATTR(dsn=&CURDSN,source=&VAR,attrib=label);
%CHK_LIST(list=&CURSTATS);
%IF &DSN ne and &HEAD ne and &STAT ne and &VAR ne and &N_GRP ne %THEN %DO;
%PUT &NAME._WORKING: !!!---Building Dummy Dataset---!!! ;
data dummy;
     length class $&CW_C ;
     class=" ";
run;
%PUT &NAME._WORKING: !!!---Dummy Dataset built---!!! ;
data &NAME(drop=i val1-val&N_GRP &CURCON
          %IF %UPCASE(&STAT) eq N %THEN
           stat;
          );
length class $&CW_C stat $&CW_S col1-col&N_GRP $&CW_D;
array  v{*} val1-val&N_GRP;
array  c{*} col1-col&N_GRP;
 %IF %UPCASE(&HEAD) eq Y %THEN %DO;
     if _N_ eq 1 then do;
       class="&LABEL";
     end;
 %END;
  set  &DSN;
select (stat);
 %DO N = 1 %TO %EVAL(&CW_D-&RSRV_INT-1);
  when ("&N"
   %DO I = 1 %TO &N_LST;
     %IF %SCAN(%SCAN(&V_LST,&I,"|"),2,"#")  eq &N %THEN %DO;
       ,"%SCAN(%SCAN(&V_LST,&I,"|"),1,"#")"
     %END;
   %END;
       )
    do;
       do i=1 to dim(c);
          c{i}=put(v{i},%EVAL(&RSRV_INT+1+&N).&N);
       end;
    end;
 %END;
  when (" "
   %DO I = 1 %TO &N_LST;
     %IF %SCAN(%SCAN(&V_LST,&I,"|"),2,"#")  eq 0 %THEN %DO;
       ,"%SCAN(%SCAN(&V_LST,&I,"|"),1,"#")"
     %END;
   %END;
       )
    do;
       do i=1 to dim(c);
          c{i}=put(v{i},&RSRV_INT..);
       end;
    end;
  when ("> %EVAL(&CW_D-&RSRV_INT-1)"
   %DO I = 1 %TO &N_LST;
     %IF %SCAN(%SCAN(&V_LST,&I,"|"),2,"#")  ge %EVAL(&CW_D-&RSRV_INT) %THEN %DO;
       ,"%SCAN(%SCAN(&V_LST,&I,"|"),1,"#")"
     %END;
   %END;
       )
    do;
       do i=1 to dim(c);
          c{i}=put(v{i},&CW_D..%EVAL(&CW_D-&RSRV_INT-1));
       end;
    end;
  when ("N","NMISS","MIN","MAX")
    do;
       do i=1 to dim(c);
          c{i}=put(v{i},6.);
       end;
    end;
  when ("MEAN","MEDIAN")
    do;
       do i=1 to dim(c);
          c{i}=put(v{i},8.1);
       end;
    end;
  when ("STD")
    do;
       do i=1 to dim(c);
          c{i}=put(v{i},9.2);
       end;
    end;
  otherwise;
end;
run;
%IF %UPCASE(&PVALUE) eq WILCOXON %THEN %DO;
  proc npar1way data=&CURDSN;
    var &VAR;
    class &CURBY;
    output out=&PVALUE(keep=p2_wil) &PVALUE;
  run;
  data &PVALUE(drop=p2_wil);
  length stat $&CW_S col&N_GRP $&CW_D;
   set &PVALUE;
       stat = "PVALUE";
       col&N_GRP = put(p2_wil,%EVAL(&RSRV_INT+7).6);
  run;
%END;
data row&CURLVL._0;
 set work.&NAME
 %IF &PVALUE ne %THEN &PVALUE;
 ;
     substr(stat,2) = lowcase(substr(stat,2));
 %IF &RECOFLAG eq Yes %THEN
     stat           = put(stat,$univ.); ;
 %IF %UPCASE(&NULLTXT) ne N %THEN %DO;
     if class eq " " then class = "_"||"&CURLVL"||"_"||compress(put(_N_,2.))||"_";
     *format class $nulltxt.;
 %END;
run;
%IF &CURCON ne %THEN %DO;
%PUT &NAME._MESSAGE: Processing context is "&CURCON = &CURVAL(&CURLAB)". ;
%END;
%PUT &NAME._MESSAGE: Reading data from %UPCASE(&DSN). ;
%PUT &NAME._MESSAGE: Output dataset %UPCASE(work.row&CURLVL._0) created. ;
%PUT ;
%END;
%ELSE %DO;
%PUT vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv;
%PUT &NAME._ERROR: Insufficient or missing Keyword Parameter(s).;
%PUT &NAME._STATUS: Macro processing abended. ;
%PUT &NAME._STATUS: Output dataset %UPCASE(work.&VAR) NOT created. ;
%PUT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^;
%GEN_MAIL(name=&NAME,rc=1);
%END;
%MEND ROW_OUTV;