BookmarkSubscribeRSS Feed
Dennis_Lam
Calcite | Level 5

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="142.172.162.252" user="r_test" ;

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

2 REPLIES 2
SASKiwi
PROC Star

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.

ballardw
Super User

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.

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 792 views
  • 0 likes
  • 3 in conversation