DATA Step, Macro, Functions and more

Questions on using SFTP to get file

New Contributor
Posts: 3

Questions on using SFTP to get file

Hi, I need to use SAS to get a .csv file using SFTP and load it into a table. I have the pub key and connection setup properly and able to get the file with the following statements. However, all data including the column header are in 1 column in the reciving table. How can I load the data into .csv file that get from the site and load it into a SAS dataset with first row as column header? I also need to rename the file after I read it. Is there anyway I can include some sftp command in my SAS script. Please advise... 


Filename SITE1 SFTP "/data/NM_TEST_20150911.csv"
Host="" user="r_test" ;

Data temp;
infile site1 truncover;
input a $5000.;

Super User
Posts: 3,111

Re: Questions on using SFTP to get file

Since you say the file is a CSV, I'm assuming that there commas between the columns. Where are they placed in the file? Please provide a sample record of the data in the file.

Super User
Posts: 10,516

Re: Questions on using SFTP to get file

If the filename statement works without problems you can use the data import wizard as a start indicating teh fileref SITE1 as the source and name the output, Library and dataset as desired.


If that works at all then the datastep code in the Log can be copied and modified to provide a bit more control of the resulting data set.

Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation