macro expand a b c ############################################################### # # # Name: EXPAND.MAC # # This macro "untallies" data by taking a frequency table and creating # from it a single column of data. # # For example, say that the numbers are in C1, the frequencies are in C2, # and you want the results stored in C3. In the Command Line Editor, or # in the Session window at the command prompt (MTB>), type: # %expand C1 C2 C3 # # C1 C2 C3 # 5 2 5 # 6 3 5 # 7 1 6 # 6 # 6 # 7 # # Note: This macro is designed to append the output to any data that may # already exist in the column specified for the output. # # ############################################################### # # Neither Minitab Inc. nor the author of this MACRO makes # any claim or offers any warranty whatsoever with regard to # the accuracy of this MACRO or its suitability for use, and # Minitab Inc. and the author of this MACRO each disclaims # any liability with respect thereto. # ############################################################### mcolumn a b c tmp brnd mconstant atmp btmp i n acnt bcnt atyp btyp noecho brief 0 notitle count a n ########## # error checking ########## dtype a atyp dtype b btyp #if atyp <> 2 or btyp <> 2 if btyp <> 2 call writerror 3 endif count a acnt count b bcnt let brnd = round(b, 0) if acnt <> bcnt call writerror 1 endif if b <> brnd call writerror 2 endif ########## # calculations ########## do i = 1:n let atmp = a(i) let btmp = b(i) set tmp (atmp)btmp end stack c tmp c enddo title brief 2 endmacro ########## macro writerror x mconstant x if x = 1 brief 2 NOTE NOTE ** Error ** Input columns have different lengths NOTE exit elseif x = 2 brief 2 NOTE NOTE ** Error ** Some values in frequency column are not integers NOTE exit elseif x = 3 brief 2 NOTE # NOTE ** Error ** Input columns need to be numeric NOTE ** Error ** Freuencies need to be integer NOTE exit endif endmacro