SED navigation bar go to SED home page go to Dataplot home page go to NIST home page SED Home Page SED Staff SED Projects SED Products and Publications Search SED Pages

Dataplot IO

Introduction As with any data analysis package, the first step in using it is typically getting your data into the program.

Dataplot can read and write variables, parameters, strings (and functions), and matrices. Data can be read directly from the keyboard or from a file.

Free Format Reads (By Default) By default, Dataplot performs free format reads. That is, data is assumed to be in an ASCII text file with variables separated by either spaces or commas (non-printing characters such as tabs are treated as spaces). Free format reading has the advantage of being flexible (data does not have to be lined up neatly, you do not have to know what format your data has), but it has the disadvantage of being slower (each line has to be parsed). Dataplot can handle real numbers, integers (stored internally as real numbers), and exponential numbers (either E or D format, both stored internally as single precision). Dataplot does not read character data except when explicitly reading strings or functions.

NOTE: Dataplot now has a ROW LABEL command for reading row labels. This is the one exception regarding the reading of character data.

Formatted Reads Available Although free format reading is the default, Dataplot does provide various commands for specifying format options. This includes commands for skipping header lines, restricting the reads to given columns, skipping comment lines in the data file, and the specification of Fortran-like FORMAT statements. Using a FORMAT statement has significant performance benefits (it is about 10 times faster than free format reading on most systems). This performance benefit is typically only an issue for large data sets. Formatted reading is rarely used for small or moderate size data sets.
Contents Dataplot contains the following commands for reading data. Dataplot contains the following commands for writing data.
IO Chapter in the Reference Manual The Dataplot Reference Manual contains a chapter specifically for I/O commands. These give detailed instructions and examples for the commands discussed here.

We have added a page that summarizes the various options for reading ASCII files in Dataplot.


Reading Data From the Keyboard

Example of Reading Data From the Keyboard The simplest way to get data into Dataplot is to read it directly from the keyboard using the READ or SERIAL READ command. For example,
    READ X Y
    130 18
    225 14
    95 25
    100 19
    170 13
    65 31
    175 14
    END OF DATA
READ Command The READ command contains a list of variables. All subsequent lines are interpreted as data lines until an END OF DATA command is encountered. Data values are separated with at least one space (or commas or tabs). Each data line is read as one row of the data variables (i.e., X(1) = 130, X(2) = 225, ... , X(7) = 175, Y(1) = 18, Y(2) = 14, ... , Y(7) = 14). Any extra data items on the line are ignored. If there are fewer data items on a line than there are variables, the missing data items are set to 0 (earlier versions of Dataplot treated this as an error).
SERIAL READ Command This data can also be read as follows:
    SERIAL READ X Y
    130 18 225 14 95 25 100 19
    170 13 65 31 175 14
    END OF DATA
Distinction Between READ and SERIAL READ The SERIAL READ command reads the data values in as X(1), Y(1), X(2), Y(2), X(3), Y(3), ..., X(7), Y(7). The SERIAL READ uses all data values on the data lines. That is, the READ command reads "down" while the SERIAL READ reads "across".
DATA Command If you have a small amount of data, the DATA command is a convenient way to create a variable. For example,
    LET X = DATA 130 225 95 100 170 65 175
    LET Y = DATA 18 14 25 19 12 31 14
READ Command in a Macro File Dataplot allows commands stored in an ASCII text file to be executed with the CALL command. The READ, SERIAL READ, and DATA commands can be used in Dataplot macro files to create data variables in the same way as they are used directly from the keyboard. For example, suppose the file PLOT.DP contains the lines
    READ X Y
    130 18
    225 14
    95 25
    100 19
    170 13
    65 31
    175 14
    END OF DATA
    PLOT Y X
The data can be read and plotted by entering the command CALL PLOT.DP.
Dataplot  / Dataplot IO ]

Reading Dataplot Data Files

Built-In Data Files Dataplot comes with a large number of previously created data files. These are stored in a special directory when Dataplot is installed. They can be accessed directly without you knowing where this directory is. For example, you can enter the commands
    SKIP 25
    READ BERGER1.DAT Y X
    PLOT Y X
    FIT Y X
Direcotries Searched for File Names When Dataplot encounters a data file on the READ command, it first looks for it in the specified directory (the current directory in the above example). If it does not find it there, it then looks for it in the directory where the Dataplot data files are stored. If your installation is unable to find these Dataplot files, contact your local site installer for assistance.
SKIP Command Most of the Dataplot data files contain header lines that identify the contents of the file. The SKIP command can be used to skip these header lines.
LIST Command The command
    LIST BERGER1.DAT (or whatever data file is of interest)
can be used to view the first few lines of the file (LIST prints the file one screen at a time) to determine how many lines should be skipped.
Dataplot  / Dataplot IO ]

Reading User Data Files

ASCII Data Files In most cases, you will typically have your data stored in a previously created file. In order to use these data files with Dataplot, the data file should be an ASCII text file. You can create the data file using a text editor or word processor, as output from a Fortran or C program, or by whatever other method is convenient. If your data is stored in the format of another software package (e.g., as an Excel spreadsheet), save the file as an ASCII text file if the package allows it. Dataplot does not currently read package specific formats such as Excel.
Rules for File Names The file name can be any valid file name for your system. Dataplot normally limits the file name to 80 characters. If the data file resides in a different directory than the one you initated Dataplot from, you need to put the path name on the file. This can be either an absolute path name or a relative path name. One caution for Unix users is that "~/" cannot be used to refer to your home directory (this is actually a C shell contstruct that is not recognized by the Unix Fortran compiler). Unix file names are case sensitive. For Unix, Dataplot will try to match the file name first as entered, then as all upper case characters, and finally as all lower case characters. This normally makes the file names case insensitive. The exception is if the file name contains a mix of upper and lower case characters. In this event, you need to enter the file name with the correct case.
Space Separated Data The data values in your files should be separated with at least one space. You can also use commas as separators. Non-printing characters (e.g., tabs) are treated as spaces. Dataplot will correctly read integer, real, and exponential (it recognizes either E or D in exponential numbers, but it will store the number internally in single precision regardless) numbers. Alphbetic characters will result in an error.
READ Command Once you have your data in an ASCII text file, you can use the READ or SERIAL READ commands to read the data.
Read Example Suppose you have a file called MYDATA.DAT with 3 data values per line and 50 lines of data. You can then read this file with the command
    READ MYDATA.DAT Y1 Y2 Y3
Period (".") Identifies a File Name Dataplot identifies MYDATA.DAT as a file name rather than a variable by the "." in the name. If your data file does not contain a period, enter a trailing period on the READ command (you do not have to rename the file to contain a period, Dataplot will match the file anyway). For example, if your data file is MYDATA, enter the command READ MYDATA. Y1 Y2 Y3. If the trailing period is omitted, Dataplot will interpret MYDATA as a variable name rather than a file.
SERIAL READ The SERIAL READ command is similar to the READ command. However, it reads "across" the data file rather than "down" the data file as the READ command does. SERIAL READ is used rather infrequently. The most common usage of SERIAL READ is when reading data for a single variable where multiple values are stored on each line.
Dataplot  / Dataplot IO ]

Reading Binary Data Files

Limited Support for Binary Files Dataplot currently has limited support for binary data files. It is limited to reading files created with Fortran unformatted write. Dataplot does not read stream binary files (as generated by C programs) or binary data files created by popular software packages such as SAS, SPSS, Excel and other spreadsheet programs. Most statistical and spreadsheet software can write their data as ASCII text files. This is the recommended procedure for transferring data from these packages to Dataplot.

The ability to read byte stream binary files (generated by C programs) and Excel format files is on our list of desirable features to add to Dataplot.

Binary Data Files Rarely Used in Dataplot Binary data files are infrequently used in Dataplot. The primary advantage of binary data files is speed. For example, a data file with 20,000 rows of data will typically take several minutes to read using the default free format reads. Using a Fortran like FORMAT typically reduces this to 10 or 20 seconds. However, using a binary read is nearly instantanaeous. A secondary advantage is that binary files are typically much smaller than ASCII text files. The primary disadvantage is that the file is no longer viewable or editable using standard text editors. In addition, the file is typically not portable to other computer systems.
Large Versions of Dataplot A few sites have created "mega" versions that are able to accomodate a maximum of 100,000 rows or more of data per variable. Binary I/O support was added primarily for these mega versions where reading large data files can be too slow using ASCII files. However, it can also be useful for the standard size Dataplot when reading data files with 10,000 to 20,000 rows (particularly if these data files are used frequently).
Fortran Unformatted Files Not Portable Across Computing Platforms Be aware that Fortran unformatted files are not pure byte streams in the sense that C binary files are. That is, the unformatted files contain header information. The Fortran standard does not define the contents or size of that header. Due to this non-standard header information and the fact that different computer systems store real numbers differently, Fortan unformatted files are not portable across computer systems. You cannot generate a Fortran unformatted write file on a Unix system and read it into the Windows PC version of Dataplot. The unformatted file must be created on the same system that Dataplot is running on.
Commands to Perform an Unformatted Read An unformatted read is accomplished by entering the following commands:
    SET READ FORMAT UNFORMATTED
    READ LARGE.DAT X1 X2 X3
    SET READ FORMAT

The SET READ FORMAT UNFORMATTED command specifies that subsequent reads should use Fortran unformatted read. Reading the file is then accomplished via the standard Dataplot READ command. The SET READ FORMAT command is entered to revert subsequent reads back to free format.

Two Ways to Create Fortran Unformatted Files There are two ways to create the unformatted file in Fortran. For example, suppose X and Y are to be written to an unformatted file. The WRITE can be generated by:
  • WRITE(IUNIT) (X(I),Y(I),I=1,N)
  • WRITE(IUNIT) X,Y
The distinction is that (1) stores the data as X(1), Y(1), X(2), Y(2), ..., X(N), Y(N) while (2) stores all of X then all of Y. There is no inherent advantage in either method in terms of performance or file size. The SET READ FORMAT UNFORMATTED command uses (1) by default. To specify (2), enter the command:
    SET READ FORMAT COLUMNWISE (or UNFORMATTEDCOLUMNWISE)
Restrictions on Unformatted Read Unformatted reading is supported only for variables or matrices (i.e., not for parameters or strings). Also, it only applies when reading from a file. The limits for the maximum number of rows and columns for a matrix still apply (500 rows and 100 columns on most systems). When reading a matrix, the number of columns must be specified via the SET UNFORMATTED COLUMNS command. For example,
    SET READ FORMAT UNFORMATTED
    SET UNFORMATTED COLUMNS 25
    READ MATRIX.DAT M
The maximum size of the file that DATAPLOT can read is equal to the workspace size on your implementation (100,000 or 200,000 points on most installations). For larger files, it will read up to this number of data values.
OFFSET and RECORDS to Control Which Portion of the File is Read The data is assumed to be a rectangular grid of data written in a single chunk. Only single precision real numbers are supported. By default, the entire file (up to the maximum number of points) is read. DATAPLOT does provide two commands to allow some control of what portion of the file is read:
    SET UNFORMATTED OFFSET <value>
    SET UNFORMATTED RECORDS <value>

The OFFSET specifies the number of data values at the begining of the file to skip. This is useful for skipping header lines (similar to a SKIP command for reading ASCII files) and other miscellaneous values. The RECORDS value is useful for reading part of a larger file.

Dataplot  / Dataplot IO ]

Formatting Input

Dataplot Commands for Reading Formatted Input Files Dataplot provides the following commands for reading formatted input files.
  1. SKIP - to skip header lines
  2. ROW LIMITS - to restrict the read to certain rows of the data file
  3. COLUMN LIMITS - to restrict the read to certain columns of the data file
  4. COMMENT CHECK ON - to specify that reads will check for comment lines when reading data files
  5. COMMENT CHARACTER - to specify the character that signifies a data line is a comment
  6. SET READ REWIND OFF - to specify that a file is not rewound after reading
  7. SET READ FORMAT - specify a Fortran like format for reading a data file
SKIP Command The most common formatting command is SKIP. Many, if not most data files, will contain some identifying comments at the beginning of the file. The SKIP command specifies the number of lines at the beginning of the data file to ignore on subsequent reads. For example,
    SKIP 25
    READ BERGER1.DAT Y X
Comment Lines in Data Files Some data files also contain comment lines interspersed between the data lines (e.g., to delineate different groups of the data, to flag a questionable data value). Entering the command COMMENT CHECK ON tells Dataplot to check for comment lines on subsequent reads. A comment line is denoted by a special character in column 1 of the data file. The default comment character is a period ".". The COMMENT CHARACTER command allows you to specify an additional character to be a comment character (the "." will be treated as a comment regardless). For example, the "#" character is a common comment character on Unix systems (COMMENT CHARACTER #). It is recommended that you not turn on comment checking unless you need it since it slows down the read. The command COMMENT CHECK OFF (the default) turns off comment checking on subsequent reads.
ROW LIMITS Command The ROW LIMITS and COLUMN LIMITS are used to restrict the read to specified rows and columns of the data file respectively. The COLUMN LIMITS is the more frequently used of these commands. It is useful for data files which contain character variables (which would result in an error if Dataplot tried to read them) or for data files in which you only want to read a subset of the the variables. Examples of these commands are
    ROW LIMITS 10 35
    COLUMN LIMITS 25 100
The ROW LIMITS command specifies the first and last rows to read while the COLUMN LIMITS command specifies the first and last columns to read.
The SET READ FORMAT Command The SET READ FORMAT command allows more specific control over the formatting than the COLUMN LIMITS. The COLUMN LIMITS work well if the variables you want to read are contiguous in the file. However, if the variables you want to read are intermixed with variables you want to skip. The SET READ FORMAT allows you to read the file once in this case instead of several times to extract each contiguous subset as the COLUMN LIMITS command would require.
SET READ FORMAT for Faster Reading The SET READ FORMAT command is also sometimes useful for obtaining better performance when reading large data files (e.g., ones with several thousand rows of data). Free format reads give sufficiently good performance for small and moderate size data sets. However, data files with 10,000 to 20,000 rows may take several minutes to read (depending on your system). Using a formatted read can speed the read up 10 - 15 times on most systems.

To perform formatted reads, enter a command like the following

    SET READ FORMAT 5(F10.5,3X)
Recognized Formats Dataplot recognizes the F, E, G, and X formats. Integer values should be read using an F format with zero decimals (e.g., F3.0). Character formats (i.e., A) should not be used. Dataplot does not perform any error checking on the specified format or compare the data file for compatibility to the format. To turn off formatted reads, enter the command
    SET READ FORMAT

By default, Dataplot opens the file before reading it.

Dataplot  / Dataplot IO ]

Reading Parameters, Strings, Functions, and Matrices

The READ and SERIAL READ Commands The READ and SERIAL READ commands read data into variables (i.e., 1-dimensional arrays or columns). Sometimes you also need to input parameters (i.e., scalars), strings, or matrices. Dataplot provides the commands READ PARAMETER, READ STRING, and READ MATRIX to do this.
Reading a Parameter To read a parameter from the keyboard, do something like the following:
    READ PARAMETER P
    23
Since only one value is being read, no END OF DATA is required. To read a parameter from a file, do something like the following:
    READ PARAMETER PAR.DAT P
where PAR.DAT is a file containing the parameter value. Dataplot identifies PAR.DAT as a file rather than a parameter by the "." in the file name. If your file name does not contain a ".", place a trailing period on the name in the READ PARAMETER command (e.g., READ PARAMETER PAR. P).
Reading Multiple Parameters If you want to read more than one parameter, there are two ways to do it. For example, suppose you want to store the parameters P1, P2, and P3 in a file. You can store all 3 values on a single line (separated by at least one space). In this case, you would enter the command READ PARAMETER PAR.DAT P1 P2 P3 to read the data. You can also store the parameters one per line. In this case, to read the parameters you would enter:
    READ PARAMETER PAR.DAT P1
    SKIP 1
    READ PARAMETER PAR.DAT P2
    SKIP 2
    READ PARAMETER PAR.DAT P3
Reading Strings To read a string from the keyboard, do something like the following:
    READ STRING S
    Washington, DC
Since only one value is being read, no END OF DATA is required. For a single string on a line, Dataplot counts everything from the first non-blank character to the last non-blank character as part of the string. In particular, do NOT enclose the string in single or double quotes. These are treated as simply another character in the string.

To read a sting from a file, do something like the following:

    READ STRTING STRING.DAT S
where STRING.DAT is a file containing the string value. Dataplot identifies STRING.DAT as a file rather than a parameter by the "." in the file name. If your file name does not contain a ".", place a trailing period on the name in the READ STRING command (e.g., READ STRING FILE. S).
Reading Multiple Strings As with parameters, there are two ways to read more than one string. For example, suppose you want to store the strings S1, S2, and S3 in a file. You can store all three values on a single line (separated by at least one space). In this case, you would enter the command READ STRING STRING.DAT S1 S2 S3 to read the strings. Alternativey, you can store the strings one per line. In this case, to read the strings you would enter:
    READ STRING STRING.DAT S1
    SKIP 1
    READ STRING STRING.DAT S2
    SKIP 2
    READ STRING STRING.DAT S3
When your strings contain spaces, you have to use the method of storing one string per line. When multiple strings are stored on a single line, Dataplot delineates them with spaces. Enclosing the individual strings in quotes does not work.
Matrices are 2-Dimensional Arrays Matrices are 2-dimensional arrays. Dataplot automatically determines the number of rows and columns in the matrix when performing the read. It assumes each data line corresponds to a single row of the matrix. If you have a large number of columns, you may need to do a formatted read (free format reads are restricted to 130 columns) or read a binary file.
Reading a Matrix From the Keyboard To read a matrix from the keyboard, do something like the following:
    READ MATRIX M 1 2 3 4 5 6 7 8 9 10 11 12 END OF MATRIX
This creates a matrix M with 3 columns and 4 rows. The columns of the matrix can be accessed as M1, M2, M3, and M4. To read a matrix from a file enter the command:
    READ MATRIX MAT.DAT M
Period (".") Identifies File Name Dataplot identifies MAT.DAT as a file rather than a parameter by the "." in the file name. If your file name does not contain a ".", place a trailing period on the name in the READ MATRIX command (e.g., READ MATRIX FILE. M).

Dataplot supports a number of special matrix commands.

Dataplot  / Dataplot IO ]

Writing Data to the Terminal

WRITE Command Used to Write to the Terminal Use the WRITE command to write the contents of a parameter, variable, string, or matrix to the terminal. PRINT is a synonym for WRITE.

By default, Dataplot prints parameters and variables using exponential notation. The Formatting Output section describes commands for generating more readable output.

Literal text can be printed by enclosing text in double quotes.

Dataplot Program Demonstrating Use of the WRITE Command The following code segment and output demonstrates the use of the WRITE command.
    FEEDBACK OFF
    DIMENSION 100 COLUMNS
    SKIP 25
    READ BERGER1.DAT Y X FOR I = 1 1 25
    FIT Y X
    FEEDBACK ON
    ECHO ON
    WRITE "Y, X, PREDICTED VALUES, AND RESIDUAL VALUES"
    WRITE Y X PRED RES
    LET STRING F = BERGER1.DAT
    WRITE "COEFFICIENTS FROM THE FIT FOR ^F"
    WRITE A0 A1
    .
    COLUMN LIMITS 20 132
    READ MATRIX AUTO79.DAT M
    WRITE "FIRST 4 COLUMNS AND 20 ROWS OF MATRIX"
    WRITE M1 M2 M3 M4 FOR I = 1 1 20
    LET CORR = CORRELATION MATRIX M
    SET WRITE DECIMALS 2
    WRITE "CORRELATION MATIRX"
    WRITE CORR
    COLUMN LIMITS 1 20
    ECHO OFF
    FEEDBACK OFF
      LOOP FOR K = 1 1 5
      LET NSKIP = K + 25 - 1
      SKIP NSKIP
      READ STRING AUTO79.DAT S^K
      WRITE "MODEL ^K IS: ^S^K"
      WRITE S^K
      END OF LOOP
The following output is printed on your terminal.
        
      ***********************************************************
      **  WRITE "Y, X, PREDICTED VALUES, AND RESIDUAL VALUES"  **
      ***********************************************************
 
      Y, X, PREDICTED VALUES, AND RESIDUAL VALUES
 
      **************************
      **  WRITE Y X PRED RES  **
      **************************
 
      
      VARIABLES--Y              X              PRED           RES     
      
 0.1800000E+02  0.2020000E+02  0.1982716E+02 -0.1827159E+01
 0.3800000E+02  0.5600000E+02  0.4243890E+02 -0.4438900E+01
 0.1500000E+02  0.1250000E+02  0.1496374E+02  0.3626033E-01
 0.2000000E+02  0.2120000E+02  0.2045877E+02 -0.4587723E+00
 0.1800000E+02  0.1550000E+02  0.1685858E+02  0.1141422E+01
 0.3600000E+02  0.3900000E+02  0.3170148E+02  0.4298519E+01
 0.2000000E+02  0.2100000E+02  0.2033245E+02 -0.3324492E+00
 0.4300000E+02  0.3820000E+02  0.3119619E+02  0.1180381E+02
 0.4500000E+02  0.5560000E+02  0.4218625E+02  0.2813746E+01
 0.6500000E+02  0.8190000E+02  0.5879768E+02  0.6202325E+01
 0.4300000E+02  0.3950000E+02  0.3201729E+02  0.1098271E+02
 0.3800000E+02  0.5640000E+02  0.4269155E+02 -0.4691546E+01
 0.3300000E+02  0.4050000E+02  0.3264890E+02  0.3510994E+00
 0.1000000E+02  0.1430000E+02  0.1610064E+02 -0.6100643E+01
 0.5000000E+02  0.8150000E+02  0.5854503E+02 -0.8545029E+01
 0.1000000E+02  0.1370000E+02  0.1572167E+02 -0.5721675E+01
 0.5000000E+02  0.8150000E+02  0.5854503E+02 -0.8545029E+01
 0.1500000E+02  0.2050000E+02  0.2001664E+02 -0.5016643E+01
 0.5300000E+02  0.5600000E+02  0.4243890E+02  0.1056110E+02
 0.6000000E+02  0.8070000E+02  0.5803974E+02  0.1960263E+01
 0.1800000E+02  0.2000000E+02  0.1970084E+02 -0.1700836E+01
 0.3800000E+02  0.5650000E+02  0.4275471E+02 -0.4754707E+01
 0.1500000E+02  0.1210000E+02  0.1471109E+02  0.2889053E+00
 0.2000000E+02  0.1960000E+02  0.1944819E+02  0.5518086E+00
 0.1800000E+02  0.1550000E+02  0.1685858E+02  0.1141422E+01
      
      **********************************
      **  LET STRING F = BERGER1.DAT  **
      **********************************
 
 
INPUT FUNCTION        = BERGER1.DAT
OUTPUT FUNCTION       = BERGER1.DAT
 
THE NAME F        HAS JUST BEEN EQUIVALENCED
TO THE FUNCTION      -- BERGER1.DAT
 
 
      *********************************************************
      **  WRITE "COEFFICIENTS FROM THE FIT FOR BERGER1.DAT"  **
      *********************************************************
 
      COEFFICIENTS FROM THE FIT FOR BERGER1.DAT
 
      *******************
      **  WRITE A0 A1  **
      *******************
 
      
      PARAMETERS AND CONSTANTS--
      
   A0      --  0.7068579E+01
   A1      --  0.6316129E+00
 
      *********
      **  .  **
      *********
 
 
      ****************************
      **  COLUMN LIMITS 20 132  **
      ****************************
 
 
THE COLUMN LIMITS (FOR READ AND SERIAL READ)
HAVE JUST BEEN SET TO       20     132
 
      ********************************
      **  READ MATRIX AUTO79.DAT M  **
      ********************************
 
 
THE NUMBER OF HEADER LINES
    BEING SKIPPED =     25
 
INPUT DATA FILE SUMMARY INFORMATION--
INPUT UNIT DEVICE NUMBER         =       31
INPUT FILE COLUMN     LIMITS     =       20         132
INPUT FILE ROW        LIMITS     =        1    INFINITY
NUMBER OF HEADER LINES SKIPPED   =       25
NUMBER OF DATA   LINES READ      =       74
NUMBER OF VARIABLES    READ      =       12
THE SCANNED REGION OF THE FIRST DATA LINE READ =
 4099 22 3 2 2.5 27.5 11 2930 186 40 121 3.58
THE SCANNED REGION OF THE LAST  DATA LINE READ =
 11995 17 5 3 2.5 29.5 14 3170 193 37 163 2.98
 
        MATRIX M       --           74 ROWS
                       --           12 COLUMNS
 
     VARIABLES        COLUMN    OBS/VARIABLE
(= COLUMN VECTORS)
        M1              3           74
        M2              4           74
        M3              5           74
        M4              6           74
        M5              7           74
        M6              8           74
        M7              9           74
        M8             10           74
        M9             11           74
        M10            12           74
        M11            13           74
        M12            14           74
 
      *****************************************************
      **  WRITE "FIRST 4 COLUMNS AND 20 ROWS OF MATRIX"  **
      *****************************************************
 
      FIRST 4 COLUMNS AND 20 ROWS OF MATRIX
 
      ****************************************
      **  WRITE M1 M2 M3 M4 FOR I = 1 1 20  **
      ****************************************
 
 
***** NOTE--
      ROW START      =        1
      ROW INCREMENT  =        1
      ROW STOP       =       20
      INPUT  NUMBER OF ROWS   =       74
      NUMBER OF ROWS AFFECTED =       20
      OUTPUT NUMBER OF ROWS   =       74
      
      VARIABLES--M1             M2             M3             M4      
      
 0.4099000E+04  0.2200000E+02  0.3000000E+01  0.2000000E+01
 0.4749000E+04  0.1700000E+02  0.3000000E+01  0.1000000E+01
 0.3799000E+04  0.2200000E+02 -0.1000000E+01 -0.1000000E+01
 0.9690000E+04  0.1700000E+02  0.5000000E+01  0.2000000E+01
 0.6295000E+04  0.2300000E+02  0.3000000E+01  0.3000000E+01
 0.9735000E+04  0.2500000E+02  0.4000000E+01  0.4000000E+01
 0.4816000E+04  0.2000000E+02  0.3000000E+01  0.3000000E+01
 0.7827000E+04  0.1500000E+02  0.4000000E+01  0.4000000E+01
 0.5788000E+04  0.1800000E+02  0.3000000E+01  0.4000000E+01
 0.4453000E+04  0.2600000E+02 -0.1000000E+01 -0.1000000E+01
 0.5189000E+04  0.2000000E+02  0.3000000E+01  0.3000000E+01
 0.1037200E+05  0.1600000E+02  0.3000000E+01  0.4000000E+01
 0.4082000E+04  0.1900000E+02  0.3000000E+01  0.3000000E+01
 0.1138500E+05  0.1400000E+02  0.3000000E+01  0.3000000E+01
 0.1450000E+05  0.1400000E+02  0.2000000E+01  0.2000000E+01
 0.1590600E+05  0.2100000E+02  0.3000000E+01  0.3000000E+01
 0.3299000E+04  0.2900000E+02  0.3000000E+01  0.3000000E+01
 0.5705000E+04  0.1600000E+02  0.4000000E+01  0.4000000E+01
 0.4504000E+04  0.2200000E+02  0.3000000E+01  0.3000000E+01
 0.5104000E+04  0.2200000E+02  0.2000000E+01  0.3000000E+01
 
      ***************************************
      **  LET CORR = CORRELATION MATRIX M  **
      ***************************************
 
 
THE NUMBER OF ROWS    GENERATED FOR THE MATRIX   CORR     =       12
THE NUMBER OF COLUMNS GENERATED FOR THE MATRIX   CORR     =       12
 
THE FIRST           COMPUTED ROW   OF CORR     =
 0.100E+01-0.476E+00-0.152E-01 0.812E-01 0.128E+00 0.430E+00 0.327E+00 0.551E+00 0.440E+00 0.259E+00
THE LAST (   12-TH) COMPUTED ROW   OF CORR     =
-0.225E+00 0.501E+00 0.132E+00 0.139E-01-0.418E+00-0.364E+00-0.437E+00-0.620E+00-0.574E+00 0.341E-01
 
THE COLUMN VECTOR NAMES ASSIGNED TO MATRIX CORR    ARE CORR1     CORR2     CORR3    ...
THE WORKSHEET COLUMNS   ASSIGNED TO MATRIX CORR    ARE       15 TO      26
 
      ****************************
      **  SET WRITE DECIMALS 2  **
      ****************************
 
 
THE FORTRAN COMMON CHARACTER VARIABLE WRITE    HAS JUST BEEN SET TO 2
 
      **********************************
      **  WRITE "CORRELATION MATIRX"  **
      **********************************
 
      CORRELATION MATIRX
 
      ******************
      **  WRITE CORR  **
      ******************
 
 
        MATRIX CORR    --           12 ROWS
                       --           12 COLUMNS
      
      VARIABLES--CORR1       CORR2       CORR3       CORR4       CORR5       CORR6       CORR7       CORR8       CORR9       CORR10  
      VARIABLES--CORR11      CORR12  
      
          1.00          -0.48          -0.02           0.08           0.13           0.43           0.33           0.55           0.44           0.26           0.50          -0.23
         -0.48           1.00           0.25           0.10          -0.41          -0.49          -0.58          -0.82          -0.80          -0.50          -0.68           0.50
         -0.02           0.25           1.00           0.75          -0.07           0.03           0.02          -0.21          -0.19          -0.16          -0.23           0.13
          0.08           0.10           0.75           1.00           0.02           0.09           0.08           0.04           0.08           0.00          -0.01           0.01
          0.13          -0.41          -0.07           0.02           1.00           0.52           0.66           0.50           0.51           0.17           0.40          -0.42
          0.43          -0.49           0.03           0.09           0.52           1.00           0.64           0.59           0.63           0.33           0.49          -0.36
          0.33          -0.58           0.02           0.08           0.66           0.64           1.00           0.68           0.72           0.41           0.57          -0.44
          0.55          -0.82          -0.21           0.04           0.50           0.59           0.68           1.00           0.96           0.61           0.87          -0.62
          0.44          -0.80          -0.19           0.08           0.51           0.63           0.72           0.96           1.00           0.61           0.80          -0.57
          0.26          -0.50          -0.16           0.00           0.17           0.33           0.41           0.61           0.61           1.00           0.72           0.03
          0.50          -0.68          -0.23          -0.01           0.40           0.49           0.57           0.87           0.80           0.72           1.00          -0.48
         -0.23           0.50           0.13           0.01          -0.42          -0.36          -0.44          -0.62          -0.57           0.03          -0.48           1.00
 
      **************************
      **  COLUMN LIMITS 1 20  **
      **************************
 
 
THE COLUMN LIMITS (FOR READ AND SERIAL READ)
HAVE JUST BEEN SET TO        1      20
 
      ****************
      **  ECHO OFF  **
      ****************
 
 
THE ECHO SWITCH HAS JUST BEEN SET TO OFF
      MODEL 1 IS: AMC CONCORD
      
      FUNCTIONS--
      
   S1      --AMC CONCORD
      MODEL 2 IS: AMC PACER
      
      FUNCTIONS--
      
   S2      --AMC PACER
      MODEL 3 IS: AMC SPIRIT
      
      FUNCTIONS--
      
   S3      --AMC SPIRIT
      MODEL 4 IS: AUDI 5000
      
      FUNCTIONS--
      
   S4      --AUDI 5000
      MODEL 5 IS: AUDI FOX
      
      FUNCTIONS--
      
   S5      --AUDI FOX
      
Dataplot  / Dataplot IO ]

Writing Data to a File

WRITE Command Use the WRITE command to write the contents of a parameter, variable, string, or matrix to the terminal. PRINT is a synonym for WRITE. When writing to a file, the first argument specifies the file name. For example,
    SKIP 25
    READ BERGER1.DAT Y X
    FIT Y X
    WRITE FIT.OUT Y X PRED RES
Period (.) Used to Identify File Name Dataplot recognizes BERGER1.DAT as a file name rather than a variable or parameter by the "." in the name. You need to put a trailing period on the file name even if do not want a file extension. For example, WRITE FIT. Y X PRED RES. It is system dependent whether or not the file is saved with the trailing period.
Exponential Format the Default By default, Dataplot prints parameters and variables using exponential notation. The Formatting Output section describes commands for generating more readable output.
Writing Literal Text Literal text can be printed by enclosing text in double quotes. This can be useful for adding header lines to data files. The SET WRITE REWIND command is usually required to put these header lines in the file. For example,
    SKIP 25
    READ BERGER1.DAT Y X
    FIT Y X
    SET WRITE REWIND OFF
    WRITE FIT.OUT "FILE: BERGER1.DAT"
    WRITE FIT.OUT "Y X PRED RES"
    WRITE FIT.OUT Y X PRED RES
Dataplot  / Dataplot IO ]

Formatting Output

WRITE Command Generates Exponential Numbers by Default The commands SET WRITE DECIMALS and SET WRITE FORMAT can be used to generate neater format from the WRITE command. By default, Dataplot prints numbers in exponential format (typically E15.7). For example,
    SKIP 25
    READ BERGER1.DAT Y X
    FIT Y X
    WRITE Y X PRED RES FOR I = 1 1 25
Dataplot Output Generated by the WRITE Command This generates the following output.
      0.1800000E+02  0.2020000E+02  0.1976212E+02 -0.1762124E+01
      0.3800000E+02  0.5600000E+02  0.4593590E+02 -0.7935900E+01
      0.1500000E+02  0.1250000E+02  0.1413257E+02  0.8674317E+00
      0.2000000E+02  0.2120000E+02  0.2049323E+02 -0.4932351E+00
      0.1800000E+02  0.1550000E+02  0.1632590E+02  0.1674098E+01
      0.3600000E+02  0.3900000E+02  0.3350701E+02  0.2492989E+01
      0.2000000E+02  0.2100000E+02  0.2034701E+02 -0.3470123E+00
      0.4300000E+02  0.3820000E+02  0.3292212E+02  0.1007788E+02
      0.4500000E+02  0.5560000E+02  0.4564346E+02 -0.6434540E+00
      0.6500000E+02  0.8190000E+02  0.6487167E+02  0.1283228E+00
      0.4300000E+02  0.3950000E+02  0.3387257E+02  0.9127433E+01
      0.3800000E+02  0.5640000E+02  0.4622834E+02 -0.8228345E+01
      0.3300000E+02  0.4050000E+02  0.3460368E+02 -0.1603678E+01
      0.1000000E+02  0.1430000E+02  0.1544857E+02 -0.5448568E+01
      0.5000000E+02  0.8150000E+02  0.6457923E+02 -0.1457923E+02
      0.1000000E+02  0.1370000E+02  0.1500990E+02 -0.5009902E+01
      0.5000000E+02  0.8150000E+02  0.6457923E+02 -0.1457923E+02
      0.1500000E+02  0.2050000E+02  0.1998146E+02 -0.4981457E+01
      0.5300000E+02  0.5600000E+02  0.4593590E+02  0.7064100E+01
      0.6000000E+02  0.8070000E+02  0.6399434E+02 -0.3994341E+01
      0.1800000E+02  0.2000000E+02  0.1961590E+02 -0.1615901E+01
      0.3800000E+02  0.5650000E+02  0.4630146E+02 -0.8301455E+01
      0.1500000E+02  0.1210000E+02  0.1384012E+02  0.1159876E+01
      0.2000000E+02  0.1960000E+02  0.1932346E+02  0.6765429E+00
      0.1800000E+02  0.1550000E+02  0.1632590E+02  0.1674098E+01
      
SET WRITE DECIMALS Command The easiest way to generate more readable numbers is to use the SET WRITE DECIMALS command. This command specifies the number of digits to use to the right of the decimal place. For example,
    SKIP 25
    READ BERGER1.DAT Y X
    FIT Y X
    SET WRITE DECIMALS 2 WRITE Y X PRED RES FOR I = 1 1 25
Generated Dataplot Output for the SET WRITE DECIMALS Command This generates the following output.
                18.00          20.20          19.76          -1.76
                38.00          56.00          45.94          -7.94
                15.00          12.50          14.13           0.87
                20.00          21.20          20.49          -0.49
                18.00          15.50          16.33           1.67
                36.00          39.00          33.51           2.49
                20.00          21.00          20.35          -0.35
                43.00          38.20          32.92          10.08
                45.00          55.60          45.64          -0.64
                65.00          81.90          64.87           0.13
                43.00          39.50          33.87           9.13
                38.00          56.40          46.23          -8.23
                33.00          40.50          34.60          -1.60
                10.00          14.30          15.45          -5.45
                50.00          81.50          64.58         -14.58
                10.00          13.70          15.01          -5.01
                50.00          81.50          64.58         -14.58
                15.00          20.50          19.98          -4.98
                53.00          56.00          45.94           7.06
                60.00          80.70          63.99          -3.99
                18.00          20.00          19.62          -1.62
                38.00          56.50          46.30          -8.30
                15.00          12.10          13.84           1.16
                20.00          19.60          19.32           0.68
                18.00          15.50          16.33           1.67
      
To resume default exponential format printing, enter the command SET WRITE DECIMALS (i.e., with no arguments).
SET WRITE FORMAT Command For maximum control, use the SET WRITE FORMAT command. This command lets you specify a Fortran like FORMAT statement. It supports the F (for floating point), E (for exponential), and X (for spaces). It does not support A (for character) or I (for integers). Integers can be printed by using an F format with 0 digits. The use of formatted output is demonstrated with the following example.
    SKIP 25
    READ BERGER1.DAT Y X
    FIT Y X
    SET WRITE FORMAT F3.0,3X,F4.1,3X,F5.2,3X,E12.4 WRITE Y X PRED RES FOR I = 1 1 25
Generated Dataplot Output for the Formatted Write This generates the following output.
      18.   20.2   19.76    -0.1762E+01
      38.   56.0   45.94    -0.7936E+01
      15.   12.5   14.13     0.8674E+00
      20.   21.2   20.49    -0.4932E+00
      18.   15.5   16.33     0.1674E+01
      36.   39.0   33.51     0.2493E+01
      20.   21.0   20.35    -0.3470E+00
      43.   38.2   32.92     0.1008E+02
      45.   55.6   45.64    -0.6435E+00
      65.   81.9   64.87     0.1283E+00
      43.   39.5   33.87     0.9127E+01
      38.   56.4   46.23    -0.8228E+01
      33.   40.5   34.60    -0.1604E+01
      10.   14.3   15.45    -0.5449E+01
      50.   81.5   64.58    -0.1458E+02
      10.   13.7   15.01    -0.5010E+01
      50.   81.5   64.58    -0.1458E+02
      15.   20.5   19.98    -0.4981E+01
      53.   56.0   45.94     0.7064E+01
      60.   80.7   63.99    -0.3994E+01
      18.   20.0   19.62    -0.1616E+01
      38.   56.5   46.30    -0.8301E+01
      15.   12.1   13.84     0.1160E+01
      20.   19.6   19.32     0.6765E+00
      18.   15.5   16.33     0.1674E+01
      
To turn off the formatted output, enter the command SET WRITE FORMAT (i.e., with no arguments).
Dataplot  / Dataplot IO ]

Writing Binary Data Files

Limited Support for Binary Data Files Dataplot currently has limited support for writing binary data files. It is limited to writing files with Fortran unformatted write. Dataplot does not write stream binary files (as generated by C binary writes) or binary data files readable by popular software packages such as SAS, SPSS, Excel and other spreadsheet programs. Most statistical and spreadsheet software can read their data as ASCII text files. This is the recommended procedure for transferring data from Dataplot to these programs.

The ability to write byte stream binary files (as generated by C programs) and Excel format files is on our list of desirable features to add to Dataplot.

Writing Binary Files is Rare in Dataplot Writing binary data files is rare in Dataplot. The primary advantage of binary data files is speed. For example, a data file with 20,000 rows of data will typically take several minutes to write using the default free format reads. Using a Fortran like FORMAT typically reduces this to 10 or 20 seconds (these times will vary depending on the speed of your hardware, but the relative performance is comparable). However, using a binary write is nearly instantanaeous. A secondary advantage is that binary files are typically much smaller than ASCII text files. The primary disadvantage is that the file is no longer viewable or editable using standard text editors. In addition, the file is typically not portable to other computer systems.

In most cases, using Fortran-like formatted read and write provides sufficient performance to make the use of unformatted read and write unnecesary.

Versions of Dataplot that Accomodate Large Data Files A few sites have created "mega" versions that are able to accomodate a maximum of 100,000 rows or more of data per variable. Binary I/O support was added primarily for these mega versions where reading and writing large data files can be too slow using ASCII files. However, it can also be useful for the standard size Dataplot when reading data files with 10,000 to 20,000 rows (particularly if these data files are used frequently). For example, you can read the original ASCII file the first time you use it, write it as a binary unformatted write file, and then read the binary file on subsequent uses of the file.
Fortran Unformatted Files Not Portable Across Computing Platforms Be aware that Fortran unformatted files are not pure byte streams in the sense that C binary files are. That is, the unformatted files contain header information. The Fortran standard does not define the contents or size of that header. Due to this non-standard header information and the fact that different computer systems store real numbers differently, Fortan unformatted files are not portable across computer systems. You cannot generate a Fortran unformatted write file on a Unix system and read it into the PC Windows version of Dataplot. The unformatted file must be created on the same system that Dataplot is running on.
Commands for Generating an Unformatted Write An unformatted write is accomplished by entering the following commands:
    SET WRITE FORMAT UNFORMATTED
    WRITE LARGE.DAT X1 X2 X3
    SET WRITE FORMAT
The SET WRITE FORMAT UNFORMATTED command specifies that subsequent writes should use Fortran unformatted write. Writing the file is then accomplished via the standard Dataplot WRITE command. The SET WRITE FORMAT command is entered to revert subsequent writes back to free format.
Two Ways to Create Unformatted Files There are 2 ways to create the unformatted file in Fortran. For example, suppose X and Y are to be written to an unformatted file. The WRITE can be generated by:
  • WRITE(IUNIT) (X(I),Y(I),I=1,N)
  • WRITE(IUNIT) X,Y
The distinction is that (1) stores the data as X(1), Y(1), X(2), Y(2), ..., X(N), Y(N) while (2) stores all of X then all of Y. There is no inherent advantage in either method in terms of performance or file size. Dataplot unformatted writes use method 1.
Some Restriction on Binary Writes Unformatted writing is supported only for variables or matrices (i.e., not for parameters or strings). Also, it only applies when writing to a file. The limits for the maximum number of rows and columns for a matrix still apply.
Dataplot  / Dataplot IO ]

Writing Parameters, Strings, Functions, and Matrices

No Special Commands Required for WRITE Unlike the READ command, no special commands are required for writing parameters, strings, and matrices. Simply use the WRITE command as you would for writing a variable. Dataplot automatically recognizes the data type and prints it accordingly.
Dataplot  / Dataplot IO ]

Generating Data

Random Numbers Dataplot provides various commands for generating data. Random numbers can be generated for 60+ distributions. For example, to generate 100 normally distributed random numbers, enter the following command:
    LET Y = NORMAL RANDOM NUMBERS FOR I = 1 1 100
SEQUENCE Command The SEQUENCE command is the most commonly used command for generating data. This command is particularly useful for creating X axis variables and group identifier variables.
Most Common Sequence There are several forms this command can take. The most common is to generate a sequence from 1 to N. For example, to create the sequence 1, 2, 3, ..., 100 enter the command
    LET TAG = SEQUENCE 1 1 100
The three numbers define a start value (1 in this example), an increment (1 in this example), and a stop value (100 in this example). These values can be real numbers (e.g., LET X = SEQUENCE 0.2 0.01 1.6). The increment can be either positive or negative.
Repeating the Entire Sequence Extending on the previous example, suppose you want to repeat the 1, 2, ..., 100 sequence for 5 groups of data. This can be generated with the command
    LET TAG = SEQUENCE 1 1 100 FOR I = 1 1 500
This repeats the sequence 1, 2, ..., 100 until 500 rows have been created.
Repeating Each Value in the Sequence Another common type of sequence is something like 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, ...., 100, 100, 100, 100. This sequence can be generated with the command
    LET TAG = SEQUENCE 1 4 1 100
The "4" in the above command is the number of times to repeat each value.
Example of the SEQUENCE Command in Generating the Grid for a Contour Plot The following example shows the use of the SEQUENCE command in generating the X and Y axis variables for a contour plot. The grid is from -4 to 4 with an increment of 1 in both the X and Y axes. The SEQUENCE command is also used to generate the contour levels (the Z0 variable).
    LET X = SEQUENCE -4 1 4 FOR I = 1 1 81
    LET Y = SEQUENCE -4 9 1 4
    LET Z = X**2 + Y**2 - X*Y
    LET Z0 = SEQUENCE 5 5 40
    CONTOUR PLOT Z X Y Z0
    SET WRITE FORMAT 3(F3.0,3X)
    PRINT X Y Z
Data Values Generated for X, Y, and Z The following values are generated for X, Y, and Z.
      -4.   -4.   16.
      -3.   -4.   13.
      -2.   -4.   12.
      -1.   -4.   13.
       0.   -4.   16.
       1.   -4.   21.
       2.   -4.   28.
       3.   -4.   37.
       4.   -4.   48.
      -4.   -3.   13.
      -3.   -3.    9.
      -2.   -3.    7.
      -1.   -3.    7.
       0.   -3.    9.
       1.   -3.   13.
       2.   -3.   19.
       3.   -3.   27.
       4.   -3.   37.
      -4.   -2.   12.
      -3.   -2.    7.
      -2.   -2.    4.
      -1.   -2.    3.
       0.   -2.    4.
       1.   -2.    7.
       2.   -2.   12.
       3.   -2.   19.
       4.   -2.   28.
      -4.   -1.   13.
      -3.   -1.    7.
      -2.   -1.    3.
      -1.   -1.    1.
       0.   -1.    1.
       1.   -1.    3.
       2.   -1.    7.
       3.   -1.   13.
       4.   -1.   21.
      -4.    0.   16.
      -3.    0.    9.
      -2.    0.    4.
      -1.    0.    1.
       0.    0.    0.
       1.    0.    1.
       2.    0.    4.
       3.    0.    9.
       4.    0.   16.
      -4.    1.   21.
      -3.    1.   13.
      -2.    1.    7.
      -1.    1.    3.
       0.    1.    1.
       1.    1.    1.
       2.    1.    3.
       3.    1.    7.
       4.    1.   13.
      -4.    2.   28.
      -3.    2.   19.
      -2.    2.   12.
      -1.    2.    7.
       0.    2.    4.
       1.    2.    3.
       2.    2.    4.
       3.    2.    7.
       4.    2.   12.
      -4.    3.   37.
      -3.    3.   27.
      -2.    3.   19.
      -1.    3.   13.
       0.    3.    9.
       1.    3.    7.
       2.    3.    7.
       3.    3.    9.
       4.    3.   13.
      -4.    4.   48.
      -3.    4.   37.
      -2.    4.   28.
      -1.    4.   21.
       0.    4.   16.
       1.    4.   13.
       2.    4.   12.
       3.    4.   13.
       4.    4.   16.
      

Privacy Policy/Security Notice
Disclaimer | FOIA

NIST is an agency of the U.S. Commerce Department.

Date created: 6/5/2001
Last updated: 10/30/2013

Please email comments on this WWW page to alan.heckert@nist.gov.