Import or export data
See Also
In addition to the GenStat spreadsheet (GSH) and book (GWB) formats, data can be imported or exported to files from a wide range of external data formats.

Importing data

Data can be imported into GenStat in several different ways. To import data into a GenStat spreadsheet or book select Open from the File item on menu bar. This will prompt you with a standard dialog where you can browse for the file to be opened. Note that if a file is opened that does not include a file extension then GenStat will try to determine the appropriate file format from the file content. When the file is opened the data will appear in a Vector spreadsheet containing variate, text and factor columns. You can then manipulate data in the usual way i.e. convert column types using the right-click menu etc...

If an external data file includes the same number of rows as a currently open spreadsheet within GenStat, then the file can be imported as additional columns within this spreadsheet. To do this select the Data file option on the Add submenu from the Spread item on the menu bar and then browse for the file to be imported.

Data can imported directly into GenStat without displaying it within a spreadsheet, To do this select the Data file option on the Load submenu from the Data item on the menu bar and then browse for the file to be imported.

To import data from a text file, except CSV files, the Load ASCII File menu should be used. This menu can be used to open data that is in column format within a text file directly into GenStat with the option of displaying the data in a spreadsheet. To do this select the ASCII file option on the Load submenu from the Data item on the menu bar and enter the relevant options on the menu for loading the data.

Data can be imported from databases using ODBC. To import data using ODBC GenStat provides a wizard that takes you through a step by step process that includes the selection of the table and construction of a simple SQL query. The ODBC Data Query wizard can initiated to import data into a spreadsheet by selecting the ODBC Data Query option on the New submenu of the Spread menu. Alternatively, the wizard can be invoked to load data directly into GenStat by selecting the ODBC Data Query option on the Load submenu of the Data menu.

When data are imported that include column names GenStat validates these. If the column names include any illegal characters these will be changed to ensure that the name is a valid GenStat identifier name. The first character of a GenStat identifier name must be a letter (or '_','%' character) and any others can be either letters, digits or '_','%' characters.

Within the command language data can be imported directly into GenStat using the IMPORT procedure and data can be retrieved from databases using the DBIMPORT procedure.

Exporting data

To export data from a spreadsheet or book select either the Save or Save As option from the File menu bar item. The Save option will save the data using its original format, overwriting the previous contents of the file. If a spreadsheet contains new data, or you select the Save As option, you can choose the file format to save the data to. Data that are exported to a spreadsheet application such as Microsoft Excel or Quattro will included the GenStat column names and data values.

Data can be exported to databases using ODBC. GenStat can create a new table in the database or you can merge or insert values into existing tables in the database. To export data using ODBC GenStat provides several menus that can be accessed on the Export submenu of the Spread menu bar item.

Within the command language data can be exported from GenStat using the EXPORT procedure and data can be exported to databases using the DBEXPORT procedure.

Hints and tips

When data are imported from spreadsheet applications such as Microsoft Excel and Quattro you can append characters to the column names to ensure columns are opened as a particular data type. For example, appending the '!' character to a column name will create the column as a factor, similarly, appending the '#' character will form a variate and the '$' character will produce a text column. When importing from Excel files the ordering of factor levels and labels can be supplied in a comment along with a column description. More information on this can be found in Using GenStat with Excel.

When data are exported to a spreadsheet application any factor columns will have the '!' character appended to the column name to ensure that the next time the spreadsheet is opened in GenStat it will be opened as a factor.

As well as importing and exporting data to files the Clipboard can be used to transfer data between GenStat and other applications. To help import data using the Clipboard, GenStat provides a menu that contains options for controlling how data are transferred from the Clipboard directly into a GenStat spreadsheet. To invoke this menu select the from Clipboard option on the New submenu of the Spread menu bar item.

When importing data from other formats such as INSTAT, SAS v7-9 and Matlab 5 you will be prompted with dialogs where you can specify additional options as to how the data are to be imported.

See Also