BookmarkSubscribeRSS Feed
kngu022
Obsidian | Level 7

Hi I have  a problem like below when I imported the data . Can anyone tell me what is wrong? 

1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         OPTIONS LINESIZE=70 PAGESIZE=80;
 74         PROC IMPORT OUT= WORK.PMSINCE1975
 75                     DATAFILE="/foldders/myfolders/Lecture_
 75       ! Resources/Chapter3";
 ERROR: Unable to determine datasource type.  Please use the DBMS= 
        option.
 NOTE: The SAS System stopped processing this step because of errors.
 NOTE: PROCEDURE IMPORT used (Total process time):
       real time           0.00 seconds
       cpu time            0.00 seconds
       
 76                     DBMS=DLM REPLACE;
 77              DELIMITER='20'x;
 78              GETNAMES=NO;
 79              DATAROW=1;
 80         RUN;
 81         
 82         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 94         


8 REPLIES 8
Tom
Super User Tom
Super User

Note that you cannot import a directory, you have to import an individual file.  Do not include a slash at the end of the filename if it is not a directory. 

 

Is your file really named Chapter3 with no extension?  If so then try just removing the trailing slash. 

 

It is possible in Windows Explorer to set the options so that it does not display the extension when it shows the filenames.  Personally I disable that option so that I always see on the screen the real names of the files and not abbreviated ones that are missing the extension.

kngu022
Obsidian | Level 7

Could you give me an example please Tom?

Kurt_Bremser
Super User

Given your other question, Chapter3 is a directory, not a file. DATAFILE needs to be file, not a directory.

"foldders" should be "folders".

And proc import needs to have the dbms= option, according to the type of the file.

kngu022
Obsidian | Level 7

Hi, 

I successfully imported dataset into SAS. I am trying to rename the variables. However, the warning shows up like the table Work.PMSINCE1975 can't be opened as it does not contain any column. Could anyone give me the solution to fix this issue please?

FILENAME pms "/folders/myfolders/Lecture_ Resources/Chapter3/pm.xlsx";
PROC IMPORT FILE=pms OUT= WORK.MyPMSINCE1975 
            DBMS=XLSX REPLACE; 
     GETNAMES=YES;
RUN;
proc datasets;
delete mypmsince1975;
run;
* renaming these variables Page 17;
DATA pmsince1975;
   SET pmsince1975;
    RENAME var1=year
           var2=party
           var3=surname;
RUN;
Tom
Super User Tom
Super User

Your program has three steps.  Tell us what they are and what each step is doing. The answer to your problem will be obvious once you have done that.

kngu022
Obsidian | Level 7

it includes 3 steps : import xlsx file into SAS : creating the file named pms

importing the file to output data WORK.MYPMSINCE1975

DBMS: indicating the type of file that is going to be imported.

deleting the Output data

 last is rename the variables. 

DATA pmsince1975 * Create the new  temporary dataset

SET an existing dataset

Rename each variable

RUN;

I know the problem comes from existing dataset because pmsince1975 does not contain any columns however I still not figure out whythis file does not contain any columns. Could you tell me please?

Screen Shot 2020-01-21 at 6.25.48 AM.png

Tom
Super User Tom
Super User

Here are your steps.

1) Create dataset (proc import)

2) Delete dataset (proc delete)

3) try to read dataset (data step)

 

Why did you create the dataset at all if you were just going to immediately delete it?

kngu022
Obsidian | Level 7

Thanks I got it. 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 8 replies
  • 938 views
  • 2 likes
  • 3 in conversation