BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
avinashginjupal
Obsidian | Level 7

I’m wondering if we have any possibility to export/import data to/from CSV files from LINUX SAS to Windows PC using PC File Server?

 

Please understand the source CSV file must be on Windows PC.

 

We are able to do this successfully with MS Excel and MS Access, but problem is with only CSV.

 

Could you help me in getting this done? I appreciate if you can get sample syntax for this.

 

Note: We can export CSV within LINUX using proc export, but that is not what I am looking for.

1 ACCEPTED SOLUTION

Accepted Solutions
avinashginjupal
Obsidian | Level 7

Test1.pngTest2.pngTest3.png

 

Then you can run code like this.

 

libname test pcfiles server='mypcfileserver.com' port=9621 dsn='mytexter';

 

data test.'mystuff.csv'n ; set sashelp.class;

run;

 

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

I think you misunderstand your problem.  Let me explain:

Excel files (*.xlsx, *.xls etc.) are Microsoft Office proprietary files.  To create these you need the Excel engine to create them.  This is only present on Windows, hence the need to use pcfiles and such like as a fill in for operating systems like Linux which do not have Office.

 

CSV on the other hand is a plain text files delimited by commas.  This file is not proprietary, can be created and read on any system by any program completely freely.  Therefore you do not need to do anything specific to create this file, and why it is far better as a data medium than Excel.

 

To create CSV on any system, you can proc export file="xyz.csv" data=abc; run;, or you could write your own datastep to do it, or any other method you are not constrained in any way.  

Do not confuse CSV as being Excel it is not.  Excel has a module which can read and interpret a CSV but it does not own that file format.

avinashginjupal
Obsidian | Level 7

I think I have found the way:

 

The way we can do this is by defining ODBC entries on the Win Server pointing to whatever folder that is that users want to use.

 

Create an ODBC driver entry for a text file and point it to the directory that you want to write to.    Then you use a named literal to create it.

 

Then you can run code like this.

 

libname test pcfiles server='mypcfileserver.com' port=9621 dsn='mytexter';

 

data test.'mystuff.csv'n ; set sashelp.class;

run;

 

Reeza
Super User

You do need the path, and possibly the TERMSTR option if you're working across OS but otherwise this is a very cumbersome way to access a CSV file.

 

You should be able to do a straight PROC IMPORT using DBMS=CSV

 

proc export data=sashelp.class outfile='path to csv file' dbms=csv replace;run;
avinashginjupal
Obsidian | Level 7

I wanted to export/import file from UNIX to WINDOWS (vice versa), if it is locally then no issues it will work but it should work on cross platforms.

Tom
Super User Tom
Super User

@avinashginjupal wrote:

I think I have found the way:

 

The way we can do this is by defining ODBC entries on the Win Server pointing to whatever folder that is that users want to use.

 

Create an ODBC driver entry for a text file and point it to the directory that you want to write to.    Then you use a named literal to create it.

 

Then you can run code like this.

 

libname test pcfiles server='mypcfileserver.com' port=9621 dsn='mytexter';

 

data test.'mystuff.csv'n ; set sashelp.class;

run;

 


Cool.  

Can you explain more about how you configured the ODBC entry?  Perhaps a screen shot from ODBC Data Sources Administator ?

 

avinashginjupal
Obsidian | Level 7

Test1.pngTest2.pngTest3.png

 

Then you can run code like this.

 

libname test pcfiles server='mypcfileserver.com' port=9621 dsn='mytexter';

 

data test.'mystuff.csv'n ; set sashelp.class;

run;

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 8161 views
  • 0 likes
  • 4 in conversation