42 4 Input and outputCELLRANGE='A2:D115'; COLUMNS=ColsDetails of the other options and parameters of IMPORT are in the on-line help.4.4 PracticalThe file Traffic.xls is an Excel data file with one worksheet called counts storing oneset of data in the area B3:D43. Use the IMPORT procedure to read the data into GenStat,converting day and month to factors. Examine the distribution of the counts using ahistogram. (Hint: use the Summarize Contents of Variates menu).4.5 Exporting data to filesGenStat spreadsheet files can be created using the FSPREADSHEET procedure. Forexample, we could create a spreadsheet file Ispread.gsh, containing the ironmeasurements from Section 4.1, by using the commandFSPREADSHEET [OUTFILE='Ispread.gsh'] sample,site,FE,weightThe OUTFILE option specifies the name (and path) of the file. If this is omitted whenGenStat is running interactively, the spreadsheet is opened as a window in the client. (Itcan then be saved, later, to a file using the Save or Save as sub-options of the File menuon the menu bar.) The data structures to put into the spreadsheet are specified by the firstparameter of the procedure, DATA. Other options and parameters allow you, for example,to add a page to a multi-page spreadsheet, to protect columns by making them read-only,to specify a title, or to save analysis commands. Full details are in the on-line help.Data can be saved in other types of file using the EXPORT procedure. For example, wecould create an Excel file Ispread.xls, containing the iron measurements from Section4.1, by using the commandEXPORT [OUTFILE='Ispread.xls'] sample,site,FE,weightThe OUTFILE option again specifies the name (and path) of the file; the file extensionxls tells EXPORT that we want to create an Excel file. The available extensions are:.XLS for Excel, .XLSX for Excel 2007, .WQ1 for Quattro, .ODS for Open OfficeSpreadsheet, .DBF for dBase, .FMT for Gauss, .SDD for SPlus, .RDA for R, .TPT forSAS transport, .TAB for tab delimited text, .WOR for Instat, .MAT for MatLab, .ARFF forWeka Attribute, .TXT for plain ASCII text, .CSV for comma delimited text, .TAB for tabdelimited text, .HTM for a HTML table, .RTF for Word Rich text format, .GSH forGenStat spreadsheet, .GWB for GenStat work book, and .BMP, .EMF, .GIF, .JPG, .TIF,.PNG or .PSD for an image file. An image file can be created either from single matrixcontaining RGB colour values, or three columns of variates or factors columns(specifying x-coordinates, y-coordinates and RGB colour values), or five columns ofvariates or factors columns (specifying x-coordinates, y-coordinates and red, green andblue colour values). The coordinate (0, 0) corresponds to the top left corner of the image,and the y-values increase as you move down the image.The SHEETNAME option allows you to specify the name of the sheet to add to an Excelfile, rather than using the default 'GenStat data'. The name should only containletters, numbers and spaces.The METHOD option controls how EXPORT behaves when asked to overwrite an existingfile. The available settings are add, append, overwrite, prompt and fail, with adefault of prompt when running interactively, and fail when running in batch.The data structures to put into the spreadsheet are again specified by the first parameterof the procedure, DATA.The COLUMNS parameter can specify names for the columns. By default, if you aresaving variates, factors or texts, their identifiers are used. The setting is a text with asingle line except for a matrix, where it should have a line for each column and also anextra initial line if the matrix has row labels.The PLAINNAMES option allows you to suppress the additional type information that
4.6 Practical 43GenStat adds by default to the column names (! for factors, etc). Alternatively, you canset option NONAMES=yes to suppress the names altogether.These are the main options and parameters that you are likely to need. Again there areothers that allow you, for example, to add a page to a spreadsheet, to specify a title, or tosave analysis commands. Full details are in the on-line help.4.6 PracticalSave the bacteria data from Practical 2.2 in an Excel file.4.7 Database filesYou can load into GenStat from an ODBC database using the DBIMPORT procedure, andsave data from GenStat into an ODBC database using the DBEXPORT procedure. Detailsare in the on-line help.4.8 Custom output and captionsThere are several commands that you can use to construct your own output. By default,in GenStat for Windows, this will appear in the Output window. Alternatively, you can usethe OPEN directive to open an external file for output, and the OUTPUT directive to sendsubsequent output there. Also, many commands have a CHANNEL option that lets youdivert output temporarily; for example, see PRINT in Section 3.1. We will not discussthis further here, but you can find the details in Sections 3.3 and 3.4 of the Guide to theGenStat Command Language, Part 1 Syntax and Data Management.The main command for output is PRINT, which was described in Section 3.1. This candisplay the contents of any GenStat data structure. It can choose appropriate styles andformats automatically, or you can set your own. For examplePRINT Sulphur,Windsp,Winddir,Rainprints the variates and factors in the pollution data set from Section 4.3, in columns downthe page. The field width is 12 characters, and the numbers of decimal places for thevariates is chosen so that their mean of the absolute values of each variate would bedisplayed to four significant figures.3 PRINT Sulphur,Windsp,Winddir,RainSulphur Windsp Winddir Rain0.00 14.80 W no13.00 14.30 N no12.00 5.50 W no22.00 5.00 NW no12.00 4.50 W no6.00 4.80 NE no2.00 4.30 E no24.00 4.00 SE no36.00 9.30 S no6.00 6.30 NE no10.00 5.80 SW yes4.00 8.30 W yes3.00 16.00 SW yes7.00 15.80 W no2.00 16.00 SW yes3.00 16.70 W yes5.00 9.50 W no6.00 9.80 W yes13.00 12.00 W yes49.00 4.80 N no26.00 2.70 W no6.00 6.50 SW no3.00 13.50 SW yes