home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / e / estat21.zip / EASIDOC.ZIP / ESCHAP07.DOC < prev    next >
Text File  |  1992-06-30  |  21KB  |  661 lines

  1.  
  2.  
  3.      Chapter 7: FILE MANAGEMENT COMMANDS
  4.  
  5.  
  6.      7:1. Data
  7.  
  8.      Format: D[ata] [s[ave]] [filename or THIS]
  9.  
  10.      This command reads in data from a file with the name
  11.      given, or if the keyword SAVE (which can be shortened
  12.      down to S) is used first the data is written to the file.
  13.      The data file is simply a text file containing a table of
  14.      numerical values arranged in columns beneath one row of
  15.      titles which determines the width of each column. The
  16.      titles consist of groups of letters or numbers separated
  17.      by spaces. There must be no blank rows in the table.
  18.      Titles and values must be separated by spaces and not
  19.      tabs. If a blank row or one beginning with the word END
  20.      is found then that will be taken as the end of the data.
  21.      This format should make it possible to transfer data
  22.      between EASISTAT files and files used by other software,
  23.      including spreadsheets, databases and word processors.
  24.  
  25.      Example data file:
  26.  
  27.      Age Sex GHQ
  28.      20   1  12
  29.       29 2    13
  30.      22  2   14
  31.      end
  32.  
  33.      "End" is optional if that is the end of the file or if a
  34.      blank line appears instead. The start of each column
  35.      position is defined by the left-most letter of each label
  36.      (A,S,G). The end of each column is defined by the start
  37.      of the next one. The end of the last column is defined by
  38.      the end of the title line, so if any data values extended
  39.      beyond the end of the first line they would not be read
  40.      in correctly (for example if 13 was replaced by 135
  41.      above, it would be read in as 13 because the 5 would be
  42.      truncated). To prevent this happening extra spaces can be
  43.      added to the end of the title line and these spaces would
  44.      be included as part of the width of the last title. This
  45.      is done automatically by EASISTAT when data files are
  46.      saved. Any blank values will be taken as zero.
  47.  
  48.      Examples:
  49.  
  50.      Select command -  DATA EXAMPLE.DAT
  51.  
  52.      Reads in data from file EXAMPLE.DAT.
  53.  
  54.      Select command -  d s fixed.dat
  55.  
  56.      Saves data in a file called FIXED.DAT. When the data set
  57.      has been narrowed down (with the NARROW command) then
  58.      only the valid rows will be saved.
  59.  
  60.      Select command -  DATA THIS
  61.  
  62.      Using the keyword THIS causes the data to be read from
  63.      the current input stream. If you are using EASISTAT from
  64.      the keyboard you can type in data as it would appear in a
  65.      
  66.        68 
  67.         File management commands  
  68.      
  69.      file. If it is being run by a command file using the
  70.      INPUT command then the data can be included as part of
  71.      the input file. It is terminated by a blank line or the
  72.      keyword "END". This allows you to keep data in one file
  73.      immediately followed by the commands to produce and
  74.      derive new columns, and to run the desired statistical
  75.      tests on the data.
  76.  
  77.      Example command file to input and modify data:
  78.  
  79.      DATA THIS
  80.      age sex beauty
  81.      26   1   2
  82.      31   2   5
  83.      16   2   9.5
  84.      end
  85.      NEW c4 CODE
  86.      DERIVE c4 1*(AGE<20) + 2*((AGE>=20)&(AGE<40)) + 3*(AGE>=40)
  87.      DERIVE c4 c4*SEX
  88.  
  89.      If this file is called DATAFILE it is read in with the
  90.      INPUT command:
  91.  
  92.      Select command - INPUT DATAFILE
  93.  
  94.      (not DATA DATAFILE, the DATA command occurs within
  95.      DATAFILE). Here the DERIVE command is used to combine AGE
  96.      and SEX to produce a new variable called CODE.
  97.  
  98.      Output:
  99.  
  100.      Widening data set to include all lines
  101.  
  102.      If a NARROW command had been issued before the data is
  103.      read in then it now ceases to apply.
  104.  
  105.      To produce a suitable data file from a word processor
  106.      just type out the data in columns as described above,
  107.      then save it to disk. If your word processor has an
  108.      option to save the text as "ASCII" or "DOS text" or "non-
  109.      document" then you must use this option. The EDIT.EXE
  110.      program supplied is a simple text editor which can be
  111.      used for creating and editing EASISTAT data files. Also,
  112.      if you have any problems reading a file with the DATA
  113.      command it would be helpful to use EDIT.EXE to study it
  114.      to see what might be causing the problem, for example any
  115.      special formatting characters that a word processor may
  116.      have introduced.
  117.  
  118.      To produce a suitable data file from Lotus 1-2-3:
  119.  
  120.      1. Select "Print", select print to "File".
  121.  
  122.      2. Select the entire range of values as the "Range" to be
  123.      printed, with a one line set of titles above if you have
  124.      one. There must be a title line above the values in the
  125.      data file, so if you do not print one out from 1-2-3 then
  126.      you must add one yourself with a word processor
  127.      afterwards.
  128.  
  129.  
  130.  
  131.      
  132.        69 
  133.         File management commands  
  134.      
  135.      3. Select "Options".
  136.  
  137.      4. Select margins and set "Left" margin to 0 and "Right"
  138.      to 240.
  139.  
  140.      5. Select "Other". Select "Unformatted" output.
  141.  
  142.      6. Go back to print (by selecting "Quit") and select
  143.      "Go".
  144.  
  145.      Warning
  146.  
  147.      EASISTAT does not make any automatic backups and does not
  148.      warn you if you are going to over-write an existing file.
  149.      Saving to the same file as the data was originally in may
  150.      be dangerous, since if you have made a mistake then the
  151.      original data will be lost. Unless you can be sure always
  152.      to specify a new filename with DATA SAVE, it is wise to
  153.      make a copy of your data file under another name or onto
  154.      another disk. You can do this before entering EASISTAT by
  155.      using the DOS command COPY, or while using EASISTAT by
  156.      using the SYSTEM COPY command to back up your data, e.g.:
  157.  
  158.      Select command -  system copy origdata.dat bkupdata.dat
  159.  
  160.  
  161.      7:2. Output
  162.  
  163.      Format: O[utput] [filename or close]
  164.  
  165.      The OUTPUT command copies all of the output from EASISTAT
  166.      that appears in the top window of the screen to a file or
  167.      to the printer. This allows you to save your results and
  168.      study them later, and means you can use a word processor
  169.      to incorporate them into a document without having to
  170.      type them all in again. When you no longer wish to send
  171.      output to the file the OUTPUT CLOSE command closes the
  172.      file and no further output is copied. OUTPUT writes on to
  173.      the end of a file, so if you choose to write to a file
  174.      which already exists whatever was previously in that file
  175.      will be left as it is and the new results will be tagged
  176.      on at the end. If you have a printer hooked up to your
  177.      computer you should be able to print out to it directly
  178.      by typing OUTPUT PRN.
  179.  
  180.      Examples:
  181.  
  182.      Select command -  OUTPUT ANOV0924.OUT
  183.  
  184.      This command copies output into the file ANOV0924.OUT. If
  185.      the file does not exist then it will be created. If it
  186.      already exists then the new output will be appended to
  187.      the old file.
  188.  
  189.      Select command -  OUTPUT 
  190.      Enter name of file to write output to: ANOV0924.OUT
  191.  
  192.      If you do not initially supply a filename, you will be
  193.      prompted for one.
  194.  
  195.  
  196.  
  197.      
  198.        70 
  199.         File management commands  
  200.      
  201.      Select command -  OUTPUT PRN
  202.  
  203.      From now on all the results will be sent to directly to a
  204.      printer if you have one connected. PRN is the special
  205.      MSDOS name for the printer. Make sure your printer is
  206.      switched on, connected and "on line" before you use this
  207.      option. If it does not work it may be because your
  208.      printer is not connected to the first parallel port of
  209.      your computer. If this is so, instead of PRN try using
  210.      LPT2, COM1 or COM2. Consult your DOS manual for details
  211.      and see the section on error messages.
  212.  
  213.      Select command -  OUTPUT CLOSE
  214.  
  215.      Output will no longer be copied to the file or printer
  216.      until another OUTPUT command is given.
  217.  
  218.      Example output:
  219.  
  220.              ********************************
  221.              *                              *
  222.              *     Output from EASISTAT     *
  223.              *     (C) ARC Scientific 1989  *
  224.              *                              *
  225.              ********************************
  226.  
  227.      This is the first thing OUTPUT will send to the results
  228.      file if it is a new file. If the file already exists only
  229.      new results will be copied onto the end of it.
  230.  
  231.      Comments
  232.  
  233.      If you use the OUTPUT command to write to a second file
  234.      when another one is already being written to then the
  235.      first file will be closed and the second file used
  236.      instead. You cannot write to two files at once, or to a
  237.      printer and a file at the same time.
  238.  
  239.      We recommend that you make extensive use of the ECHO
  240.      command to provide titles and comments in your output
  241.      file so that when you refer to it later you will be able
  242.      to remember what each test was supposed to do. See the
  243.      section on the ECHO command.
  244.  
  245.      Using OUTPUT for printing results
  246.  
  247.      Although it is possible to print off results straight
  248.      away using PRN as the filename, in general we would
  249.      recommend that you should send the results into a file
  250.      instead and then use a word processor, the EDIT.EXE
  251.      program or the DOS PRINT command (see your DOS manual) to
  252.      print off the file when you have finished using EASISTAT.
  253.      If you have the results saved in a file on disk then you
  254.      have a permanent record which can be printed off as many
  255.      times as you like, and in addition you can edit them and
  256.      incorporate them directly into a larger document without
  257.      onerous retyping.
  258.  
  259.  
  260.  
  261.  
  262.  
  263.      
  264.        71 
  265.         File management commands  
  266.      
  267.      7:3. Input
  268.  
  269.      Format: I[input] [filename [param1 param2 ....] or close]
  270.  
  271.      Causes a command file to be read in. Command files
  272.      contain commands exactly as they would be typed at the
  273.      keyboard.
  274.  
  275.      Examples:
  276.  
  277.      Select command - IN COMM0911.LOG
  278.  
  279.      Select command -  i 
  280.      Enter name of file to read input from (KEY for keyboard): 
  281.      demo
  282.  
  283.      If you do not initially supply a name for the file then
  284.      EASISTAT will ask for it.
  285.  
  286.      Select command -  i close
  287.  
  288.      The keyword CLOSE means finish the command file now, as
  289.      if the end of the file had been reached.
  290.  
  291.      It is also possible to pass replaceable parameters to a
  292.      command file as one can with DOS batch files. These
  293.      parameters are typed on the EASISTAT command line after
  294.      the file name, and are then substituted wherever %1, %2
  295.      ... %10 appear in the command file. If you have an input
  296.      file called EXAMPLE that contains the following line:
  297.  
  298.      ECHO parm1 %1 parm2 %2 parm3 %3
  299.  
  300.      then entering:
  301.  
  302.      Select command -  INPUT EXAMPLE one two testing
  303.  
  304.      will produce the following output:
  305.  
  306.      parm1 one parm2 two parm3 testing
  307.  
  308.      The original purpose of this was to allow you to perform
  309.      the same set of tests repeatedly on different columns,
  310.      but it is a very flexible feature and can be used in a
  311.      variety of other ways as well.
  312.  
  313.      Comments
  314.  
  315.      Command files are a powerful feature of EASISTAT. Long
  316.      and complex analyses can be prepared in advance on a word
  317.      processor and then can be run automatically without
  318.      supervision. As you grow more familiar with EASISTAT you
  319.      shold learn to use command files extensively.
  320.  
  321.      The file on your disk called DEMO is a command file.
  322.      Please study it to see how it works. Note that you can
  323.      also input a command file when you first run EASISTAT by
  324.      entering e.g. EASISTAT DEMO. This causes EASISTAT to read
  325.      in the command file called DEMO, exactly as if you had
  326.      typed INPUT DEMO instead once EASISTAT was running. This
  327.      facility means EASISTAT analyses can be run as part of
  328.      DOS batch files (in fact the demonstration is usually run
  329.      
  330.        72 
  331.         File management commands  
  332.      
  333.      by a batch file called DEMO.BAT Which contains the line
  334.      EASISTAT DEMO).
  335.  
  336.      Normally if EASISTAT finds an error in a command file it
  337.      will pause and ask whether to continue or jump to the end
  338.      of the file or relinquish control to the keyboard. You
  339.      may want to prevent this happening and for EASISTAT to
  340.      continue even if it does find errors, perhaps because you
  341.      wish to perform some long analyses while the computer is
  342.      unattended. To do this use the /I switch in the command
  343.      line after the file name:
  344.  
  345.      EASISTAT A-LONG.JOB /I
  346.  
  347.      In this mode EASISTAT will not stop for errors or pauses
  348.      in the command file. It may be wise to put a few blank
  349.      lines between each command in the command file, so that a
  350.      mistake in one does not cause the next to be misread.
  351.  
  352.      Normally when a graphing option is chosen for one of the
  353.      EASISTAT commands the graph file will be written to disk
  354.      and then EASIGRAF will be run automatically. However
  355.      EASIGRAF is not run if a command file is being used,
  356.      although the graph file is still written to disk.
  357.      Similarly the usual pause does not occur after the
  358.      execution of a SYSTEM command.
  359.  
  360.      Command files can be nested up to five deep, that is one
  361.      command file can contain an INPUT command to read in
  362.      another, and so on. The second will be read through and
  363.      when it finishes control is returned to the first file.
  364.      It is possible for a command file to transfer control
  365.      temporarily to the keyboard as if the keyboard was
  366.      another file. To do this the keyword KEY is used:
  367.  
  368.      INPUT KEY
  369.  
  370.      Since the keyboard doesn't end the way a file does, the
  371.      only way to get back to the original file is to type:
  372.  
  373.      INPUT CLOSE
  374.  
  375.      Unless the /I switch has been used, every time the
  376.      command file comes across the PAUSE command or an error
  377.      is found the user is given the option of taking temporary
  378.      control at the keyboard by typing K. He or she can later
  379.      return to the command file by using the INPUT CLOSE
  380.      command. A command file can also be made to pause between
  381.      commands by pressing CONTROL-C or CONTROL-BREAK.
  382.  
  383.      Any line in an input file starting with a semi-colon is
  384.      ignored. This can be used to put explanatory comments and
  385.      reminders into input files.
  386.  
  387.      Here is an example of a fairly complex command file which
  388.      takes the names of two columns as parameters and performs
  389.      Wilcoxon's signed rank sum test to compare them. If the
  390.      file were called WILCSR.INP then one would run it by
  391.      entering:
  392.  
  393.  
  394.  
  395.      
  396.        73 
  397.         File management commands  
  398.      
  399.      INPUT WILCSR.INP C14 C15
  400.  
  401.      to compare columns 14 and 15.
  402.  
  403.      ECHO Command file "WILCSR" to perform signed rank sum test
  404.      ECHO     comparing %1 and %2
  405.      LABEL V1 N'
  406.      LABEL V2 T1
  407.      LABEL V3 T2
  408.      LABEL V4 VAR
  409.      LABEL V5 MEAN
  410.      ; use convenient labels to refer to the first four general
  411.      ; variables
  412.      NEW NEXT DIF
  413.      DERIVE DIF %1 - %2
  414.      ; create a new column called DIF, the difference between the
  415.      ; two columns to be compared
  416.      NARROW %1 != %2
  417.      ; ignore rows in which the values are equal
  418.      DERIVE DIF ABS DIF
  419.      DERIVE DIF RANK DIF
  420.      ; alter DIF to contain the ranks of the absolute magnitudes
  421.      ; of the differences between the columns
  422.      BASICS DIF
  423.      DERIVE N' XNUMBER
  424.      BASICS DIF IF %1>%2
  425.      DERIVE T1 XTOTAL
  426.      BASICS DIF IF %1<%2
  427.      DERIVE T2 XTOTAL
  428.      ; now N' contains the number of rows used, T1 is the total of
  429.      ; the ranks of the differences for which the first column is
  430.      ; larger and T2 of those for which the second is larger
  431.      DERIVE VAR N'*(N'+1)*(2*N'+1)/24
  432.      DERIVE MEAN 0.25*N'*(N'+1)
  433.      ECHO Here are the values for T1, T2 and N':
  434.      ARITH T1
  435.      ARITH T2
  436.      ARITH N'
  437.      ECHO Standardised normal deviate (with continuity correction) is:
  438.      ARITH (ABS(T1-MEAN)-0.5)/(VAR POW 0.5)
  439.      ECHO
  440.      ECHO Approximate P value (single-tailed) is:
  441.      ARITH 1-PN((ABS(T1-MEAN)-0.5)/(VAR POW 0.5))
  442.      ; the expected mean and variance are used to calculate the
  443.      ; standardised normal deviate and therefore significance of the
  444.      ; result (ties are ignored)
  445.      DEL DIF
  446.      ; finally, the new column created is deleted
  447.  
  448.      The built-in Wilcoxon's signed rank sum test is somewhat
  449.      superior to this command file because it takes account of
  450.      tied ranks. However this example is designed to
  451.      demonstrate the way in which additional statistical tests
  452.      not built into EASISTAT can be constructed by hand if
  453.      desired.
  454.  
  455.      Another way to use command files might be to set up some
  456.      batch files which will run certain simple tests
  457.      automatically. For example, the following batch file
  458.      called CHISQ.BAT can be run from DOS to perform a two-by-
  459.      two chi-squared test:
  460.  
  461.      
  462.        74 
  463.         File management commands  
  464.      
  465.      rem CHISQ.BAT
  466.      if exist chisq.out del chisq.out
  467.      echo output chisq.out > chisq.inp
  468.      echo chisq n 2 2 >> chisq.inp
  469.      echo %1 %2 >> chisq.inp
  470.      echo %3 %4 >> chisq.inp
  471.      echo quit >> chisq.inp
  472.      echo y >> chisq.inp
  473.      easistat chisq.inp
  474.      type chisq.out
  475.  
  476.      This batch file uses the parameter substitution feature
  477.      and ECHO command of DOS (not EASISTAT) to produce a
  478.      command file for EASISTAT called CHISQ.INP. If the batch
  479.      file were run from DOS as follows:
  480.  
  481.      CHISQ 6 12 34 10
  482.  
  483.      then CHISQ.INP would contain the following lines:
  484.  
  485.      output chisq.out
  486.      chisq n 2 2
  487.      6 12
  488.      34 10
  489.      quit
  490.      y
  491.  
  492.      When EASISTAT is run the commands in CHISQ.INP are read
  493.      in just as if the command INPUT CHISQ.INP had been given
  494.      from within EASISTAT. These commands instruct EASISTAT to
  495.      send its output to a file called CHISQ.OUT, then to
  496.      perform a chi-squared test on a two-by-two table with the
  497.      values specified, and then to quit and return to DOS.
  498.      Control is thus returned to the batch file which uses the
  499.      TYPE command to display CHISQ.OUT on the screen.
  500.  
  501.  
  502.      7:4. Log
  503.  
  504.      Format: Lo[g] [filename or close]
  505.  
  506.      Produces command files by copying keyboard input to a
  507.      file. This log file can then be read in again as a
  508.      command file, or it can be edited and elaborated first.
  509.      This is a very useful way to get started creating command
  510.      files.
  511.  
  512.      All the commands typed in at the keyboard are copied into
  513.      the file with the name specified, until the command is
  514.      reissued with the filename CLOSE (which cannot be
  515.      abbreviated). This provides a very useful record of the
  516.      commands typed in during a session. It would then be
  517.      possible to repeat exactly the same sequence of commands
  518.      on another occasion just by using the INPUT command to
  519.      read in the commands from the log file. Alternatively the
  520.      file can be adjusted with a text editor such as EDIT.EXE
  521.      before being read in again.
  522.  
  523.  
  524.  
  525.  
  526.  
  527.      
  528.        75 
  529.         File management commands  
  530.      
  531.      Examples:
  532.  
  533.      Select command - log stat0927.log
  534.  
  535.      Copies all commands into STAT0927.LOG.
  536.  
  537.      Select command - log close
  538.  
  539.      Closes file so that no further commands will be copied.
  540.      Like the OUTPUT command, LOG writes onto the end of a
  541.      pre-existing file.
  542.  
  543.  
  544.      7:5. Echo
  545.  
  546.      Format: E[cho] text
  547.  
  548.      Echoes input to output, allowing comments and titles to
  549.      appear in output files, or for command files to explain
  550.      themselves on screen as they run.
  551.  
  552.      Example:
  553.  
  554.      Select command -  e    The title of the next test is this
  555.  
  556.      Everything on the line after the echo command is copied
  557.      to the output, that is into the top window of the screen
  558.      and into an output file if one has been opened. This is
  559.      very useful for entering explanatory notes about the
  560.      tests one is doing into an output file, because it may be
  561.      quite hard when reading them later to work out what is
  562.      going on.
  563.  
  564.      See the DEMO file for examples of the use of the ECHO
  565.      command (the E at the start of most lines is invoking
  566.      ECHO).
  567.  
  568.  
  569.      7:6. Pause
  570.  
  571.      Format: P[ause]
  572.  
  573.      Produces a pause in a command file.
  574.  
  575.      Example:
  576.  
  577.      Select command -  p
  578.  
  579.      Output:
  580.  
  581.      A pause has occurred in the input command file 
  582.      'E' to end file, 'K' to use keyboard, any other key to continue
  583.  
  584.      The pause allows the user to read what has appeared on
  585.      screen. It also gives him or her the chance to abort the
  586.      command file, by pressing E, or to take temporary control
  587.      of EASISTAT as if the INPUT KEY command had been issued,
  588.      by pressing K. In the latter case he or she can return
  589.      later to the command file (which remains open) by
  590.      entering INPUT CLOSE (to finish keyboard input).
  591.  
  592.  
  593.      
  594.        76 
  595.         File management commands  
  596.      
  597.      This command is ignored if EASISTAT has been run with the
  598.      /I switch, which causes it to ignore errors and pauses.
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.      
  660.        77 
  661.