Hello,
I am trying to import big excel file (4429 rows and 125 columns) into sas but I am getting an error.
Here is my code
PROC IMPORT DATAFILE="C:\Users\bmrg2\Box Sync\Mizzou 2019\Research\RBI Project\Task 8_Back-casting\NBI Data from Fhwa site\ID 2019\ID19.xlsx"
DBMS=xlsx
OUT=ID19 REPLACE;
SHEET='ID19';
RUN;
PROC PRINT DATA=ID19;
RUN;
Here is the log result:
119 PROC PRINT DATA=ID19;
ERROR: File WORK.ID19.DATA does not exist.
120 RUN;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
I am new and have a hard time figuring out what is wrong.
You need a semi-colon after DBMS=xls.
proc import datafile="C:\Users\bmrg2\Box Sync\Mizzou 2019\Research\RBI Project\Task 8_Back-casting\NBI Data from Fhwa site\ID 2019\ID19.xls"
out=outID19
DBMS=xls
; /* Semi colon needed here */
Sheet="sheet1";
Getnames=Yes;
run;
Jim
You need to show the LOG for the Import step since that is supposed to create the data set that Proc Print should display.
Just a basic check before we go to far: Is the sheet name ID19? Many times, the sheet names will not be the same as the file name, so, although basic, it's important to check. The sheet name should be spelled exactly as listed at the bottom of the Excel window. In the below example, I have four sheets (Summary, Pivot, Data, and Values), any one of which could be brought in via Proc Import.
Jim
Yes the sheet name is ID19 same as the file name.
OK, good.
Next question: Was the Excel spreadsheet closed when you tired the import? If not, SAS will give your the (very) misleading message "does not exist" when in fact all that needs to occur is to close the Excel spreadsheet. Please make sure the spreadsheet is closed and try again.
Jim
It was opened but when I close the excel file I get this log result:
26 proc import datafile="C:\Users\bmrg2\Box Sync\Mizzou 2019\Research\RBI Project\Task
26 ! 8_Back-casting\NBI Data from Fhwa site\ID 2019\ID19.xls"
27 out=newID19
28 DBMS=xls
29 replace;
30 Sheet="sheet1";
31 Getnames=Yes;
32 run;
ERROR: Physical file does not exist, C:\Users\bmrg2\Box Sync\Mizzou 2019\Research\RBI
Project\Task 8_Back-casting\NBI Data from Fhwa site\ID 2019\ID19.xls.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.04 seconds
cpu time 0.00 seconds
Well, let's check the basics. Can you post a screen capture of a Windows Explorer session showing that directory and that file? See example, below. We should confirm that the file hasn't been accidentally moved or misspelled before we look at other issues.
After that, we should check the sheet name. Sheet1 is the default and it's highly likely that is in fact the sheet name, but we should still check.
Jim
The last ERROR or WARNING is always the least important, the first the most important. Fixing the first usually cleans up most, if not all, following problems.
So you fix your code top-down, and when you need help, you need to show the log from the whole code of the first step that causes a problem.
You need a semi-colon after DBMS=xls.
proc import datafile="C:\Users\bmrg2\Box Sync\Mizzou 2019\Research\RBI Project\Task 8_Back-casting\NBI Data from Fhwa site\ID 2019\ID19.xls"
out=outID19
DBMS=xls
; /* Semi colon needed here */
Sheet="sheet1";
Getnames=Yes;
run;
Jim
So I just fixed it as you said and I realize my file name extension was "xlsx" and not "xls". I corrected it this is what I get in the log which I supposed my data were imported. However, how do I move it from the "work" library to a permanent library? sorry for my dumb question
33 /*PROGRAM FOR RBI RESEARCH STATE OF IDAHO OCTOBER 10 2020*/
34 proc import datafile="C:\Users\bmrg2\Box Sync\Mizzou 2019\Research\RBI Project\Task
34 ! 8_Back-casting\NBI Data from Fhwa site\ID 2019\ID19.xlsx"
35 out=newID19
36 DBMS=xlsx
37 replace;
38 Sheet="sheet1";
39 Getnames=Yes;
40 run;
NOTE: One or more variables were converted because the data type is not supported by the V9
engine. For more details, run with options MSGLEVEL=I.
NOTE: The import data set has 4493 observations and 123 variables.
NOTE: WORK.NEWID19 data set was successfully created.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 5.40 seconds
cpu time 5.36 seconds
Never mind a simple copy and paste did the work.
Thanks a lot
Excellent. Sounds like we're all set then..👍
Jim
You can use libraries wherever you use datasets, so you only need to add the library in your PROC IMPORT statement:
proc import
datafile="C:\Users\bmrg2\Box Sync\Mizzou 2019\Research\RBI Project\Task 8_Back-casting\NBI Data from Fhwa site\ID 2019\ID19.xlsx"
out=permlib.newID19
DBMS=xlsx
replace
;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.