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.
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;
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.
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;
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;
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.
@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 ?
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;
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.