home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / xactus.zip / macros / stat.xc$ / xsmp32 / os2 / uk / stat.xcd
Text File  |  1994-09-29  |  2KB  |  71 lines

  1. /* try macro */
  2. Parse Arg handle
  3.  
  4.     Say "This macro opens a table document and " ||,
  5.         "defines and selects all columns. Then it computes the "||,
  6.         "descriptive statistics, extracts mean and standard deviation "||,
  7.         "and writes these to the end of the table document. "||,
  8.         "The resulting table document is then presented as a table "||,
  9.         "chart using a stylesheet."
  10.  
  11.     tHandle = XR_OpenTab("TABLES\N10G8.XTF")     /* Open the table */
  12.  
  13.     Call XR_Select tHandle, "All", "SELECT"      /* Select all columns */
  14.     Call XR_SetColTyp tHandle, "YL"              /* Set column types */
  15.  
  16.     newHandle = XR_Statistics(tHandle)           /* Compute descr. statistics */
  17.  
  18.     Call XR_SwapMatrix tHandle                   /* Rotate the data in the table */
  19.  
  20.     Call getColumnValues newHandle, 2            /* get the mean values from the stat window */
  21.     colNo = setColumnValues(tHandle)             /* and write them to the end of the table */
  22.     Call XR_WriteCell tHandle, 0, colNo, "Mean"  /* set the colum title */
  23.  
  24.     Call getColumnValues newHandle, 3                /* get the standard deviations */
  25.     colNo = setColumnValues(tHandle)                 /* and write them to the end of the table */
  26.     Call XR_WriteCell tHandle, 0, colNo, "Std.Dev."  /* set the column title */
  27.  
  28.     Call XR_CloseWindow(newHandle)               /* close the stat window */
  29.  
  30.     /* use a stylesheet and rescale */
  31.     gHandle = XR_UseStyleSheet(tHandle, "STSHEET\TAB.STL", 1)
  32.  
  33. Exit
  34.  
  35. /*************************************************************************
  36.  * getColumnValues
  37.  *
  38.  * Writes the values from column 'colNo' into the stem variable 'val'
  39.  *************************************************************************/
  40.  
  41. getColumnValues: procedure expose val.
  42.     Parse Arg handle, colNo
  43.  
  44.     total = XR_NumOfLines(handle)
  45.  
  46.     Do  i = 0 To total
  47.         val.i = XR_ReadCell(handle, i, colNo)
  48.     End
  49.  
  50.     val.0 = total
  51.  
  52. Return
  53.  
  54. /*************************************************************************
  55.  * setColumnValues
  56.  *
  57.  * Writes the values from the stem variable 'val' into a new column.
  58.  *************************************************************************/
  59.  
  60. setColumnValues: procedure expose val.
  61.     Parse Arg handle
  62.  
  63.     colNo = XR_GetColNum(handle, 1, "UNUSED")
  64.  
  65.     Do  i = 1 To val.0
  66.         Call XR_WriteCell handle, i, colNo, val.i
  67.     End
  68.  
  69. Return colNo
  70.  
  71.