MACRO TWO BOBO

Aus phenixxenia.org
Version vom 28. Oktober 2014, 15:53 Uhr von Wolf-Dieter Batz (Diskussion | Beiträge)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Zur Navigation springen Zur Suche springen

Zurück

Übersicht

Vorwärts

Workflow Graph Module Type
MACRO TWO BOBO.png
User module from Phase-III Macro System based on Fractal System Architecture. Build super row (=block) from boolean selections nested in boolean selection.

Source

Start Definition with Parameters and Defaults

%MACRO TWO_BOBO(dsn=,use=,use2=,row=,row2=,col=,indent=0,indinc=2,num=,total=T,stat=Y,weight=Y,rev=N,space=2,condense=,struct=,struct2=,head=Y,head2=N) / store des="Create hierarchy from two boolean vars";

Declares and Upper Level Processing

%LOCAL n_lst v_lst row_n use_n n_grp v_grp n i name;
%LET name=TWO_BOBO;
%IF &STRUCT  eq %THEN %LET struct =&DSN;
%CHK_LIST(list=&ROW2);
%GRP_DESC(dsn=&DSN,grp=&ROW,miss=n);
%TOP_FILT(dsn=&DSN,grp=&ROW,grp2=,by=&COL,grplvl=&NUM,var=,condense=&CONDENSE);
%TOP_FREQ(dsn=top_filt,struct=&STRUCT,grp=&ROW,by=&COL);
%TOP_OUTC(dsn=top_freq,head=&HEAD,total=&TOTAL,stat=&STAT,indent=&INDENT,grp=&ROW,rev=&REV,use=&USE,by=&COL);
%IF &STRUCT2 eq %THEN %LET struct2=top_filt;

Loop for Lower Level Processing

%DO n=1 %TO &N_LST;
  %LET row_n = %SCAN(%SCAN(&V_LST,&N,|),1,#);
  %LET use_n = %SCAN(%SCAN(&V_LST,&N,|),2,#);
  %DO i=1 %TO &N_GRP;
    %IF %SCAN(&V_GRP,&I,|) eq &USE2 %THEN %DO;
      %ROW_FILT(dsn=&DSN,context=&ROW,subgrp=&I,grp=&ROW_N,by=&COL,var=,miss=n);
      %ROW_FREQ(dsn=row_filt,sum=top_freq,struct=&STRUCT2,context=&ROW,grp=&ROW_N,by=&COL,weight=&WEIGHT);
      %LET cursub=&N;
      %ROW_OUTC(dsn=row_freq,sum=,head=&HEAD2,stat=&STAT,indent=%EVAL(&INDENT+&INDINC),context=&ROW,grp=&ROW_N,use=&USE_N,by=&COL);
    %END;
  %END;
%END;

Care for Naming and Send Completion Mail

%IF &TAB_NAME ne %THEN %DO;
  data %SUBSTR(&TAB_NAME,1,3)&NUM%SUBSTR(&TAB_NAME,5,4);
   set
     row&NUM._0(where=(class not contains "Missing"))
     %IF &SPACE eq 1 %THEN dummy;
  %DO n=1 %TO &N_LST;
     %IF &SPACE eq 2 %THEN dummy;
     row&NUM._&N
  %END;
     %IF &SPACE eq 2 %THEN dummy;
     row&NUM._0(where=(class contains "Missing"))
     %IF &SPACE eq 3 %THEN dummy;
   ;
  run;
%END;
%GEN_MAIL(name=&NAME);

Close Definition

%MEND TWO_BOBO;

Parameters

Name Values Description
dsn string input dataset name
row, row2 string categorial variable name, 2=list of nested_var#true_value
rev Y/N output decodes of &ROW in reverse order
use, use2 string select decode from &ROW, 2=decode from &ROW used as nesting context
weight Y/N multiply percentages for &ROW and &ROW2
col string categorial variable name used for columns
total T/I/B/O/N/TC/IC/BC/OC/NC define vertical position of totals
head, head2 Y/N block header, 2=nested variable
indent, indinc n number of indent columns and increment for nested variable
num n sequence number of output
stat Y/N column with statistics names
space 1/2/3 blank line before or after output and between nesting levels
struct, struct2 string name of reference dataset used for full decode structure, 2=nested variable
condense var#value non-distinct variable and true value for &ROW
misslin2 Y/N force missing line for nested variable