DATA Step, Macro, Functions and more

Import a csv file from C drive

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 9
Accepted Solution

Import a csv file from C drive

Hi,

 

I want to import a file placed in my C drive. However, when I am using import option I am unable t do so.

code used:

%let source_file = 'C:\Users\USCUXK04\DESKTOP\sasddpo_md_realignment_table.xlsx';


PROC IMPORT
DATAFILE=&source_file
OUT=WORK.STAGE_MD_REALIGNMENT_TABLE
DBMS=XLSX
REPLACE;
RUN;

 

 

ERROR: Physical file does not exist, /sasconfig/Lev1/SASApp/C:\Users\USCUXK04\DESKTOP\/sasddpo_md_realignment_table.xlsx.

 

by default EG is taking unix path configured, how can i import the file


Accepted Solutions
Solution
‎04-18-2017 07:22 PM
PROC Star
Posts: 7,363

Re: Import a csv file from C drive

Here is the response from @ChrisHemedinger (who helped create EG) a couple of years ago:

 

As others have pointed out, your EG installation and your data files are on your PC, but your SAS Workspace session (where the code runs) is on a different box, and the library path you specified isn't valid.  You can get your data files to where they need to be by using Tasks->Data->Upload Data Sets to Server.  That task will transfer your local data files into a SAS library that you select.

 

Art, CEO, AnalystFinder.com

 

View solution in original post


All Replies
Solution
‎04-18-2017 07:22 PM
PROC Star
Posts: 7,363

Re: Import a csv file from C drive

Here is the response from @ChrisHemedinger (who helped create EG) a couple of years ago:

 

As others have pointed out, your EG installation and your data files are on your PC, but your SAS Workspace session (where the code runs) is on a different box, and the library path you specified isn't valid.  You can get your data files to where they need to be by using Tasks->Data->Upload Data Sets to Server.  That task will transfer your local data files into a SAS library that you select.

 

Art, CEO, AnalystFinder.com

 

Community Manager
Posts: 2,761

Re: Import a csv file from C drive

Just one modification to Art's answer: if you're dealing with a CSV file or XLSX file, you'll have to use Tasks->Data->Copy Files.  The Upload SAS Data Sets task applies just to sas7bdat files that you're loading into a SAS library.  The Copy Files task allows you to copy any file from your local PC to an folder on the remote SAS machine.

 

Copy Files was added in EG 7.13.  Before that, it's available as a custom task that you can easily add to EG.

Super User
Posts: 17,823

Re: Import a csv file from C drive

I thought you could also use the GUI to import a local excel file. However this can't be automated via a program. 

Super User
Posts: 10,500

Re: Import a csv file from C drive

And why does the subject say "CSV File" and your filename reference an XLSX file????

If the file is actually CSV the proc import would fail because the file format does not match the import options specified.

 

Spelling counts in computer programs.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 170 views
  • 1 like
  • 5 in conversation