Try the following as an example:
In order the rearrange the order of the fields (PIN and AGE) in the ACROSS, you need to twist the data so that the totals for these two are on physically separate records. Hence the need for the SAVE file and the MFD with the usage of OCCURS and ORDER. This probably could also be accomplished with the MacGyver Technique but I chose this way instead.
Give it a test and pick it apart to learn how it works. the only thing it doesn't have is TITLEs for the Year Totals.
DEFINE FILE PERSINFO
BIRTHDEC/YY='2006';
BIRTHQTR/Q=BIRTHDATE;
BIRTHMTH/M=BIRTHDATE;
CNTSPOUSE/I9=IF (RELATIONSHIP EQ 'SPOUSE') THEN 1 ELSE 0;
CNTSIBLING/I9=IF (RELATIONSHIP EQ 'BROTHER' OR 'SISTER') THEN 1 ELSE 0;
CNTPARENT/I9=IF (RELATIONSHIP EQ 'FATHER' OR 'MOTHER') THEN 1 ELSE 0;
END
TABLE FILE PERSINFO
SUM CNTSPOUSE CNTPARENT
BY BIRTHDEC
SUM CNTSPOUSE CNTPARENT
BY BIRTHDEC
BY BIRTHQTR
BY BIRTHMTH
WHERE BIRTHDEC EQ '2006'
ON TABLE SAVE AS 'THEDATA'
END
-RUN
APP FI THEMFD DISK THEDATA.MAS
-RUN
-WRITE THEMFD FILENAME=THEDATA, SUFFIX=FIX,$
-WRITE THEMFD SEGNAME=ONE, SEGTYPE=S0,$
-WRITE THEMFD FIELDNAME=BIRTHDEC , , FORMAT=YY, ACTUAL=A4,$
-WRITE THEMFD FIELDNAME=CNTSPOUSE, , FORMAT=I9, ACTUAL=A9,$
-WRITE THEMFD FIELDNAME=CNTPARENT, , FORMAT=I9, ACTUAL=A9,$
-WRITE THEMFD FIELDNAME=BIRTHQTR , , FORMAT=Q , ACTUAL=A1,$
-WRITE THEMFD FIELDNAME=BIRTHMTH , , FORMAT=A2, ACTUAL=A2,$
-WRITE THEMFD SEGNAME=MTHTOTS, SEGTYPE=S0, PARENT=ONE, OCCURS=2,$
-WRITE THEMFD FIELDNAME=CNTMONTH , , FORMAT=I9, ACTUAL=A9,$
-WRITE THEMFD FIELDNAME=CNTORDER , ALIAS=ORDER, FORMAT=I2, ACTUAL=I4,$
-WRITE THEMFD DEFINE CNTTYPE/A8=DECODE CNTORDER(1 'Spouses' 2 'Parents');$
TABLE FILE THEDATA
SUM MAX.CNTSPOUSE AS '' MAX.CNTPARENT AS ''
SUM CNTMONTH AS ''
ACROSS BIRTHDEC AS ''
ACROSS CNTTYPE AS ''
ACROSS BIRTHQTR NOPRINT COLUMNS 'Q1'
ACROSS BIRTHMTH AS '' ACROSS-TOTAL AS 'Total'
ON TABLE SET STYLE *
TYPE=REPORT, COLUMN=MAX.CNTSPOUSE, SEQUENCE=5,$
TYPE=REPORT, COLUMN=MAX.CNTPARENT, SEQUENCE=10,$
ENDSTYLE
END
Thanks!
Mickey
| FOCUS/WebFOCUS 1990 - 2011 |