BookmarkSubscribeRSS Feed
Pdogra
Calcite | Level 5

Hi there,

Sounds trivial? 

but I have been having problems reading files

If I invoke the drop down fucntionality unders files -> import data and point to a location and try reading the files I have no problems and it generates the following code:


DATA WORK.test_for_sas2;
    LENGTH
        name             $ 3
        acc_no             8 ;
    FORMAT
        name             $CHAR3.
        acc_no           BEST1. ;
    INFORMAT
        name             $CHAR3.
        acc_no           BEST1. ;
    INFILE 'E:\saswork\_TD7416\#LN00368'
        LRECL=5
        ENCODING="WLATIN1"
        TERMSTR=CRLF
        DLM='7F'x
        MISSOVER
        DSD ;
    INPUT
        name             : $CHAR3.
        acc_no           : ?? BEST1. ;
RUN;

To me it seems that SAS internally copies the file to our SAS server (EG) and reads it in, but If i change the infile statement from above to  point to server location where I want to read from (for automation purposes)

e.g. infile   '\\sdax.server.ca\sftp_read\file.csv'  it gives me an I/O error. I am stumped.

This server location is an SFTP folder for our vendors to drop the csv. I want to automate the process of reading the files, but can't do so.

Would you have an idea , how to read it in? I can't use windows shell command to copy (as this functionality in SAS EG is disabled and our admin won't allow this) the files to another location and read it in. BTW if I copy this file to our SAS EG server location and point to that location using infile statement, SAS works and reads the file, So I am guessing it is some sort of the settings on this folder /server which is preventing SAS to read.

Please help ?

Thanks,

PD

9 REPLIES 9
Doc_Duke
Rhodochrosite | Level 12

PD,

I don't know the "solution" to your problem, but I do have a workaround that I have used.

I use the system scheduler (in Windows XP, it is "Scheduled Tasks" in the Control Panel) to copy the file from the external site to a file structure that I can get to (you can run your FTP commands through a .BAT file).  Then I have another scheduled task to go off a few minutes later to run the EGuide or batch SAS part.

Doc Muhlbaier

Duke

Tom
Super User Tom
Super User

You need to talk to your IT support about allowing your SAS server to access the folder that you are accessing from your PC with Enterprise Guide.

If it really is an FTP server then try using the FTP engine on the FILENAME statement (or the INFILE statement).

Minaxi_Patel
Calcite | Level 5

Remove TERMSTR=CRLF option from infile statement. I hope it will work. I had a same issue and it worked for me.

Dil
Calcite | Level 5 Dil
Calcite | Level 5

hi,

I had the exactly same problem today. When I imported the csv file manually, it was fine and it created similar codes as yours. However, when I used the proc import, it is giving me errors for two of the numeric variables, which I double checked that they don't have any unusual values or any symbols. Need to figure this out too.

Ksharp
Super User

Maybe you need add another option   guessingrows=32767   to avoid such error when you are using proc import for CSV file.

Dil
Calcite | Level 5 Dil
Calcite | Level 5

Thanks Xia Keshan. I didn't have any problem. when I used guessingrows=32767 option. The thing is all the numeric variables including sas date variables all became character variables. Any suggesion on resolving this issue? Thanks.

ChrisHemedinger
Community Manager

You can use this method to copy a file from anywhere a FILENAME statement can reference: FTP, HTTP, and SFTP.

You won't need to run additional shell commands or FTP scripts.  For SFTP, you will need a OpenSSH or PUTTY (depending on Windows or Unix) to be configured for your SAS environment.  See the FILENAME SFTP access method documentation.

Chris

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Kurt_Bremser
Super User

At least in 9.2 on AIX, filename SFTP does not work reliably. SAS routinely tries to read past the end of the temporary file; it basically "overtakes" the file transfer process.

I had to run the file transfer manually via X and then read the copied file.

jakarman
Barite | Level 11

>>> INFILE 'E:\saswork\_TD7416\#LN00368'

This is an automatic naming of a temporary file being uploaded to the server. If this is your remote server your SAS server is a Windows machine.

As the used local saswork is a temporary one you will get a different name the next time.

That code is useless to get automated.

>>> infile   '\\sdax.server.ca\sftp_read\file.csv'    ???

That is not ftp acess method is a URI name in your Windows domain.  You are probably referring to a location where text files using a sftp-tool are dropped for you. 

Most SAS installations are not setup to be part of the AD domain. Your SAS-platform admin should cooperated with AD windows and central identity security.

Only in that way you could define the authorization settings getting all the data in the AD domain accessible.    

---->-- ja karman --<-----

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 4276 views
  • 1 like
  • 9 in conversation