Importing xlsx by a program

Reply
Occasional Contributor
Posts: 9

Importing xlsx by a program

Hi,

Working on Enterprice Guide, I usually import files using the wizard (File -> Import Data). It works perfectly, but I would like to use a program in order to make it more dynamic with macros.

Copying completely the code generated by the wizard inside a new program, it doesn't work.

It seems that the name of the file is typed as a comment and the INFILE instruction it is replaced by "__AS_work7D3A000037C7_sapmop41/#LN00058". I replaced it with the correct path

but it still doesn't work. The output is generated but the contents is corrupted (strange symbols).

How can I solve the problem?

This is the code:

          ..

          ..

        INFILE '___/SAS_work7D3A000037C7_sapmop41/#LN00058'

        LRECL=194

        ENCODING="LATIN1"

        TERMSTR=CRLF

        DLM='7F'x

        MISSOVER

        DSD ;

          ..

          ..

Super Contributor
Posts: 349

Re: Importing xlsx by a program

Hi Carmine,

What version of EG you are using..it works fine for me with 4.3 Version.

DATA WORK.test1;

    LENGTH

        F1               $ 6

        F2               $ 2 ;

    FORMAT

        F1               $CHAR6.

        F2               $CHAR2. ;

    INFORMAT

        F1               $CHAR6.

        F2               $CHAR2. ;

    INFILE 'C:\DOCUME~1\test\LOCALS~1\Temp\SAS Temporary Files\_TD6124\#LN00008'

        LRECL=9

        ENCODING="WLATIN1"

        TERMSTR=CRLF

        DLM='7F'x

        MISSOVER

        DSD ;

    INPUT

        F1               : $CHAR6.

        F2               : $CHAR2. ;

RUN;

or you can just use Proc import  procedure.

Thanks,

Shiva

Occasional Contributor
Posts: 9

Re: Importing xlsx by a program

I'm using the 4.3 too. But applying my settings (of Length, format, informat and input) and replacing

your Infile, it doesn't work.. Smiley Sad

Occasional Contributor
Posts: 9

Re: Importing xlsx by a program

That's not so elegant but finally I solved the problem leaving the import-object pointing always the same file

but replacing the input-file with the new one. Simply using unix commands from SAS. The new file path is prompt by the user.

If someone needs, I can post the program..

N/A
Posts: 1

Re: Importing xlsx by a program

Hi Carmine, I have the exactly same problem with SAS 4.3 now. Please could you send me the script you used?  my email is zhenghaouk@hotmail.co.uk

Many thanks

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