static DataObject CreateFromExcelFile( <String sName,> String sPathName, String sSheetName <, boolean bUseFirstRowAsVarNames, boolean bReadMixedTypesAsStrings> )
The return value is a reference to the newly created object of the DataObject class.
String sPathName
The filename of, and optionally the path to, the Microsoft Excel workbook file to use to populate the DataObject. See Remarks for more information.
String sSheetName
The name of the worksheet within the Microsoft Excel workbook file to use to populate the DataObject.
String sName
The name to assign to the DataObject.
boolean bUseFirstRowAsVarNames
If bUseFirstRowAsVarNames is true, the values in the first row of the worksheet are interpreted as variable names. If bUseFirstRowAsVarNames
is false, the variables in the DataObject are assigned the names F1, F2, F3, etc. Calling this method without specifying bUseFirstRowAsVarNames
is equivalent to calling it with bUseFirstRowAsVarNames equal to true. See Remarks for additional details.
boolean bReadMixedTypesAsStrings
If bReadMixedTypesAsStrings is true, IMLPlus converts all values in a column to text if the column contains a mixture of character and
numeric values. If bReadMixedTypesAsStrings is false, IMLPlus does not convert numeric values to text if the column contains mostly
numeric values. Calling this method without specifying bReadMixedTypesAsStrings is equivalent to calling it with bReadMixedTypesAsStrings
equal to true. See Remarks for additional details.
This method creates an object of the DataObject class and populates it with data from the specified Microsoft Excel worksheet. If you do not specify the parameter sName, the filename (excluding the extension) is used as the name of the DataObject.
IMLPlus performs the following steps to locate the file specified by the sPathName parameter:
You can configure the Data File Search Path using the Directories tab of the Options dialog box.
If the parameter bUseFirstRowAsVarNames is true, IMLPlus interprets the values in the first row of the worksheet as variable names. IMLPlus applies the following transformations to convert a value in the Excel worksheet to a valid SAS variable name:
For each column in the Excel worksheet, IMLPlus must decide whether to treat the column as a numeric variable or as a character variable. To make this determination, IMLPlus examines the first eight values in the column. Based on the data types of those values and on the setting of the parameter bReadMixedTypesAsStrings, IMLPlus assigns a data type to the variable as shown in the following table:
% Numeric / % Character (first eight values) |
bReadMixedTypesAsStrings = true |
bReadMixedTypesAsStrings = false |
---|---|---|
100 / 0 | Numeric | Numeric |
0 / 100 | Character | Character |
50 / 50 | Character | Character |
51 - 99 / 49 - 1 | Character | Numeric |
49 - 1 / 51 - 99 | Character | Character |
declare DataObject dobj; /* Change the next line to point to your Excel file. */ pathname = "C:\My Excel Files\SomeExcelFile.xls"; sheetname = "Sheet1"; dobj = DataObject.CreateFromExcelFile( pathname, sheetname ); DataTable.Create( dobj ).ActivateWindow();