BookmarkSubscribeRSS Feed
maggi2410
Obsidian | Level 7

Hi ,

I have an excel file, which columns having length around 500-600 chars. I have to convert this to SAS dataset, in UNIX.

I am trying to use the excel libname with PCFILES statement, but it has one more argument , ie SERVER. Now I am not very sure, what should be its value.

I am running the code using XTERM. But the SAS Code and excel file are on some other drive, say U drive. If the server name is of U drive , then how could I find out its server name. Any thoughts?

6 REPLIES 6
SASKiwi
PROC Star

My understanding if you are trying to read Excel from Unix is that you must also have a Windows computer running the SAS PC File Server software along with MS Office installed. It is this computer that handles the conversion of Excel spreadsheets into a form that SAS understands.

If you are after a quick fix you could try saving the excel file into a CSV and then you should be able to import it without the above complications.

Quentin
Super User

Agree with SASKiwi

server= is the name of the Windows server where the PC files server is running.

BASUG is hosting free webinars Next up: Mike Sale presenting Data Warehousing with SAS April 10 at noon ET. Register now at the Boston Area SAS Users Group event page: https://www.basug.org/events.
SandorSzalma
Fluorite | Level 6

Hi,

you should give a try with PROC IMPORT.

It supports Export/Import with XLS, XLSX files on Unix Platfrom, too.

(SAS OnlineDoc: PROC IMPORT, Supported Data Sources and Environments)

Regards,

Sándor

maggi2410
Obsidian | Level 7

Actually I dont have PC SAS. SAS is installed on other servers, and I submit the code via XTERM. Now, everytime I submit the code, I guess, whichever server is free, the code is submitted on that. So its random. What do you think in this case, can I still use PCFILES?

For now, I am converting the sheet into dab delimited file and then reading it. It is still truncating the columns , maximum length being 201. The code I am using is:

data temp.temp1     ;

    infile '../test.txt' delimiter='09'x MISSOVER DSD lrecl=800 firstobs=3 ;

              length chg_ref    $800;

              format _all_;informat _all_;           

         input     chg_ref    ;

    run;

Do you think there is any problem in this. This UNIX system is getting on my nerves now. Smiley Sad

SandorSzalma
Fluorite | Level 6

does this U: drive point to a shared-filesystem on the Unix server, where SAS runs?

(Samba-Share?, U:\ -> SAS_Server:/xx/yy)

If yes, you can use PROC IMPORT without PC File Server, too.

TimArm
Obsidian | Level 7

I also agree with SASKiwi; I cannot use proc import with Excel files on my AIX server.

If you are using a data step, you could try using the termstr=CRLF option on the infile statement - if your file was saved on a Windows platform.

SandorSzalma is correct that you can still use proc import on unix, as it can still be used to read text files (delimited).

HOWEVER, if you use proc import with a tab delimited file it only looks at the first 2 rows by default to guess variable lengths. You can change this by using the GUESSINGROWS= option.

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!

Discussion stats
  • 6 replies
  • 2308 views
  • 0 likes
  • 5 in conversation