Database Reference
In-Depth Information
Example 3.3 - Part 2.
If we want only part of the input Excel file, there are several ways to go about getting just what we want. The
following code brings in only a few cells from the input Excel file. Here, we will also suppress the request to
pull the variable names from the first row of the input data, since we are pulling data from the middle of the
Excel file.
PROC IMPORT
DATAFILE='c:\My_Files\Shoes.xls'
DBMS=EXCEL
OUT=shoes
REPLACE;
GETNAMES=NO;
RANGE='shoes$C2:F4'n;
RUN;
This SAS code does that job. The added command “GETNAMES=NO” and the modification of the
“RANGE=” operand are the key parts of this SAS code. The SAS output file looks something like the
following:
Figure 3.1: SAS Output from Reading the Excel Range Using Absolute Addressing of Excel
Cells.
Only 12 cells were read from the Excel worksheet called “SHOES” and the SAS variable names were converted
to F1, F2, F3, and F4 because the GETNAMES=NO statement suppressed reading any variable names. The
“RANGE=” worksheet name value was in lowercase and included the location of the Excel cells to read into the
SAS dataset.
Example 3.3 - Part 3
Users of Excel Workbooks have the option of creating subsets of cells in a worksheet that can be called by
name; these areas are called Named-Ranges. Figure 3.2 below shows one of these named ranges called
“small_range”. The range name was created while running Excel with the workbook Shoes.xls open.
 
Search WWH ::




Custom Search