DATA Step, Macro, Functions and more

importing a text file using proc import in EG

Reply
Learner
Posts: 1

importing a text file using proc import in EG


Hi,

I am trying to import a text file proc import in EG.  The issue is that SAS isn't able to locate the the client machine where the file actually sits.  I've tried the following code in Exhibit 1 using the server option, but I don't think that is vali in proc import.  I also tried to import the file using infile (see Exhibit 2).  Still uses referencing the location of the file so SAS knows where to point to.  Any suggestions?  Thank you so much!! Smiley Happy

Exhibit1: proc import with server =

proc import

     datafile=\\server\folder\file.txt

     out=mydata

     dbms=dlm replace;

     delimiter='|';

     getnames=yes;

     datarow=2;

     options validvarname=v7;

     server=&_CLIENTMACHINE;

run;

 

Exihibit 2: Referencing file using infile

DATA myshared.FAZAL;

    LENGTH

        hicn                               $ 12

        consumer_point_of_sale             $ 18

        agent_point_of_sale                $ 1

    LABEL

        hicn                               = "HICN"

        consumer_point_of_sale             = "Consumer Point Of Sale"

        agent_point_of_sale                = "Agent Point Of Sale"

          INFORMAT

        hicn                               $CHAR12.

        consumer_point_of_sale             $CHAR18.

        agent_point_of_sale                $CHAR1.

     

     INFILE &FILENAME

        LRECL=339

        ENCODING="LATIN1"

        TERMSTR=CRLF

        DLM='7F'x

        MISSOVER

           SERVER=&_CLIENTMACHINE

        DSD ;

    INPUT

        hicn                               : $CHAR12.

        consumer_point_of_sale             : $CHAR18.

        agent_point_of_sale                : $CHAR1.

       ;

RUN;

Super User
Posts: 3,112

Re: importing a text file using proc import in EG

Try enclosing your filename in quotes:

datafile="\\server\folder\file.txt"

Super User
Posts: 6,948

Re: importing a text file using proc import in EG

If the file "sits" on another system than the one that runs SAS, you need one of many mechanisms to access files on the remote (remote from the POV of SAS) system:

- shared network volumes on file servers

- ftp/sftp

- direct share of volumes (eg with nfs)

- SAS/CONNECT if both machines have SAS installed and CONNECT is licensed

If you have separate systems, how do they communicate/share data?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 10,516

Re: importing a text file using proc import in EG

You Server session may not appropriate permissions or mapping to see the source.

Ask a Question
Discussion stats
  • 3 replies
  • 838 views
  • 0 likes
  • 4 in conversation