Database Reference
In-Depth Information
Output Log of Code Above
1
2
3 PROC IMPORT
4 DATAFILE='c:\My_Files\Shoes.xls'
5 DBMS=XLS
6 OUT=shoes
7 REPLACE;
8 ENDCOL="4"; /* a quoted string is required */
9 STARTCOL="2"; /* a quoted string is required */
10 ENDROW=10; /* numeric value is required */
11 STARTROW=6; /* numeric value is required */
12 NAMEROW=1;
13 GETNAMES=NO;
14 RUN;
NOTE: Variable Name Change. Number of Stores -> Number_of_Stores
NOTE: The import data set has 5 observations and 3 variables.
NOTE: WORK.SHOES data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.06 seconds
cpu time 0.01 seconds
Figure 3.5b: Using PROC IMPORT to Select Rows and Headers from an Excel Worksheet.
Example 3.7 PROC IMPORT Using the DBMS=XLS or XLSX to Select Excel
Ranges
This example was executed on a computer running 64-bit Windows 8.1 Professional on 64-bit hardware with
SAS 9.4 and 32-bit Excel 2013 installed. The DBMS option XLSX provides an alternative method to reading a
small group of cells from an Excel spreadsheet. However, this method does not always provide reliable variable
names when GETNAMES=YES. GETNAMES=YES looks for variable names in the first row of input cells.
Here, GETNAMES=NO is used to turn off the search for variable names in the Excel file. The
RANGE='shoes$C2:F4'n command selects only 12 cells from the Excel file.
PROC IMPORT
DATAFILE='c:\My_Files\Shoes.xlsx'
DBMS=XLSX
OUT=shoes
REPLACE;
GETNAMES=NO;
RANGE='shoes$C2:F4'n;
RUN;
 
Search WWH ::




Custom Search