BookmarkSubscribeRSS Feed
KevinC_
Fluorite | Level 6

Hello Everyone,

I am trying to 'import' a text file from PC to Unix.  I have tried using the code below with no success.  I wonder if anyone knows a different approach?

Proc Import out = DNL

database= "c:\My Docs\Denials.txt"

DBMS=TAB Replace;

Getnames=Yes;

Datarow=2;

Run;

When I submit this code from Unix it just sits there without generating an error code or any output.  I always end up killing the job later.  Does anyone have any suggestions on how to get data from PC to Unix?  This needs to be done within a SAS program, meaning no manual intervention, as this is an automated process.

I really appreciate any input! Smiley Happy

12 REPLIES 12
Ksharp
Super User

Can you post a txt file you imported.

Maybe your txt file is not really txt file, it is a delimiter file. or try.

DBMS=dlm Replace;

delimiter='|' ;

KevinC_
Fluorite | Level 6

Thank you, Ksharp.

Here is a sample of the text file I am trying to import.  It is tab delimited.  Hence the 'DBMS=TAB replace" in my code.

"ID"  "Client"  "C_Code"

"0001298477"  "743"  "41"

"0003876533"  "654"  "20"

Any suggestions?

Thanks again.

Haikuo
Onyx | Level 15

Hi,

One possible lazy approach is to using infile statment and pre-assign a large length to include all of your variables.

data dnl;

  infile "c:\My Docs\Denials.txt" dsd dlm='09'x firstobs=2;

  input (ID Client C_Code) (:$15.);

run;

Haikuo

KevinC_
Fluorite | Level 6

Thank you, HaiKuo.

I ran your code and received an error stating "the physical file does not exist".  It seems to look for the file on the Unix server and can't find it.  This is part an automated program so  manual upload is not preferred.

Any other suggestions?

I really appreciate your help! Smiley Happy

Haikuo
Onyx | Level 15

So you are running SAS on Unix server. Then you need the correct network mapping address for your txt file, or you need to do FTP. Check SAS docs on "filename ftp".

Haikuo

KevinC_
Fluorite | Level 6

I have the correct network mapping.  I looked up the FTP stuff and don't really know how it applies to my situation.

Does Proc Import even work on Unix?

Haikuo
Onyx | Level 15

Well, "c:\My Docs\Denials.txt" does NOT look like a network address to me. Proc import will work the same on Unix as it works on PC, but you do need to input the address that Unix can recognize. "c:\My Docs\Denials.txt" is clearly a windows address.

Haikuo

update: Let me restate it clearly, you need to either map "c:\My Docs\Denials.txt" as a network address that Unix can access, Or you need to use FTP to bring this file to your Unix server.

KevinC_
Fluorite | Level 6

Thanks for your reply.

Since this is an automated process, both approaches (a Unix-reconizable directory or FTP) will need to require no manual intervention.  That is the part I am having difficulties with.  I can easily FTP the file or run proc import from PC SAS.

Is there a way to automatically FTP a file from a windows directory to a UNIX directory - meaning including it as part of the code?

Thank you.

Haikuo
Onyx | Level 15

If you can't have your windows address mounted ( this is only need to be done one time), then try the following FTP approach:

Step 1: Make sure your PC or Windows server has FTP server running. Check this with your Windows team, if not, then you need to install FTP server service and make it active. This is only need to be done one time.

Step 2:

filename myfile ftp ' \Denials.txt ' cd= 'c:\My Docs\ '

  user='xxx'

pass=xxx

  host='network name or ip address of your pc or win server'

  recfm=v ;run;

data dnl;

  infile myfile dsd dlm='09'x firstobs=2;

  input (ID Client C_Code) (:$15.);

run;

Good luck,

Haikuo

Ksharp
Super User

I found a problem in your code.

database= "c:\My Docs\Denials.txt"

should be

datafile= "c:\My Docs\Denials.txt"

and your sample data is not delimited by TAB ,but a white space.

Proc Import out = DNL

datafile= "c:\My Docs\Denials.txt"

DBMS=dlm Replace;

Getnames=Yes;

Datarow=2;

delimiter=' ';

Run;

Recommend to use webdev to map your local PC fold to UNIX , then you can directly use this path to import this file into UNIX.

filename x webdev 'your-path' ;

..................

Ksharp

KevinC_
Fluorite | Level 6

Thank you Ksharp for your suggestion.

I have modified my code according to your suggestion.  The code still sits there without generating any output or errors.

I wonder if my Unix environment has been 'setup' to handle proc import.  Is there some kind of command(s) I need to run in my Unix folder before using proc import?

Ksharp
Super User

"I wonder if my Unix environment has been 'setup' to handle proc import. "

I am afraid that your UNIX is not ready for it . You need the help from your UNIX administrator .

Let him use SIMBA (a software can mount a Windows folder on a UNIX directory ), at that time , you can use the proc import as I suggested.

Good Luck.

Ksharp

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 12 replies
  • 4568 views
  • 0 likes
  • 3 in conversation