# GROUPL.MAC # # Groups a data set. Display uses class limits and class marks. # # Macro is for MINITAB for Windows, release 10 and above # Written by: J. David Lifsey, Georgia Perimeter College, 770-393-9525 # # Date: 04/12/00 MACRO GROUPL Z # Z CONTAINS THE DATA TO BE GROUPED. MCOLUMN C D F G H M P R S V Z LC UC Head1 Head2 Head3 Head4 Head5 Title1 T1 T2 T3 T4 T5 MCONSTANT a b i k l n u w nd ans xmax TotFreq TotRF NOTITLES # SUPPRESSES TITLES IN SESSION-WINDOW OUTPUT. BRIEF 2 NOTE NOTE This macro obtains a grouped-data table using equal-width classes where: NOTE NOTE Lower class limit = the smallest value that can go in a class. NOTE Upper class limit = the largest value that can go in a class. NOTE Class mark = average of lower and upper class limits of a class NOTE Class width = difference between the lower class limit of a class NOTE and the lower class limit of the next higher class. NOTE NOTE Data values are limited to the range: 000.000 through 999.999. NOTE When decimals are present, they must be accounted for NOTE in specifying the first LCL and UCL values. NOTE NOTE Enter in order: NOTE >>>First LOWER CLASS LIMIT. NOTE >>>First UPPER CLASS LIMIT. NOTE >>>CLASS WIDTH. NOTE SET D; FILE 'TERMINAL'; NOBS 3. NOTE NOTE >>>>> Enter a table HEADING describing the data values: (60 char max). BRIEF 0 SET Title1; FILE 'TERMINAL'; FORMAT (A60); NOBS 1. # D(1)= Entered LCL of first class. # D(2)= Entered UCL of first class. # D(3)= Entered class width. # Title1= Descriptive table heading for values to be grouped. COPY Z C; # Copy input data values in Z to new column C. OMIT Z='*'. # Omit missing values; C has only good values. LET n=N(C) # Number of observations. LET xmax=MAX(C) # Largest observation. LET w=D(3) # Class width. LET LC(1)=D(1) # LCL of first class. LET UC(1)=D(2) # UCL of first class. LET M(1)=(D(1)+D(2))/2 # Class mark of first class. LET u=UC(1) # UCL comparison value. LET k=1 # Initial class. WHILE u=a) AND (C<=b) # Check if data value is between a and b. LET F(i)=SUM(D) # Frequency for class i. LET P(i)=F(i)/n # Relative frequency for class i. ENDDO DO i=0:100 # Determine number of decimal places in data values. LET S=10**i*C ROUND S R LET S=(S=R) LET a=SUM(S) IF a=n LET nd=i # Determined number of decimal places. GOTO 1 ENDIF ENDDO MLABEL 1 Sum F TotFreq # Total of the frequency column. Sum P TotRF # Total of the relative frequency column. Let T3(2) = Totfreq # Places total frequency in T3(2). Let T4(2) = Totrf # Places total relative frequency in T4(2). Text T3 T3 # Converts T3 to Text. Text T4 T4; # converts T4 to text. Deci 4. # Sets to 4 decimal places. # # Heading and footer text values. Let Head1(1) = "Lower" Let Head1(2) = "Class" Let Head1(3) = "Limit" Let Head1(4) = "-------" Let Head2(1) = "Upper" Let Head2(2) = "Class" Let Head2(3) = "Limit" Let Head2(4) = "-------" Let Head3(3) = "Freq" Let Head3(4) = "-----" Let Head4(2) = "Rel" Let Head4(3) = "Freq" Let Head4(4) = "------" Let Head5(2) = "Class" Let Head5(3) = "Mark" Let Head5(4) = "--------" Let T1(2) = "TOTAL" Let T3(1) = "-----" Let T4(1) = "------" Let T2(2) = " " Let T5(2) = " " MULTIPLY P 10000 P # Rounds relative frequency to 4 decimal places. ROUND P P DIVIDE P 10000 P SET V; # Places heading string in V. FORMAT (A18). Grouped-Data Table END BRIEF 2 WRITE V; # Prints above heading string. Format (A18). WRITE Title1; # Prints descriptive title of data values. Format (A60). Text LC LC; # Converts LCL column to text. Deci nd. Text UC UC; # Converts UCL column to text. Deci nd. Text F F # Converts frequency column to text. LET nd=nd+1 Text M M; # Converts class mark column to text. Deci nd. Text P P; # Converts relative frequency column to text. Deci 4. # Stacks all grouped information into # text columns Head1-5. Stack (Head1 Head2 Head3 Head4 Head5) (LC UC F P M) (T1 T2 T3 T4 T5) (Head1 Head2 Head3 Head4 Head5) # # Prints the grouped-data table. Write Head1 Head2 Head3 Head4 Head5; FORMAT (A7,3X,A7,3X,A5,3X,A6,3X,A8). TITLES # RESTORES TITLES IN SESSION-WINDOW OUTPUT ENDMACRO