BookmarkSubscribeRSS Feed
luj
Calcite | Level 5 luj
Calcite | Level 5

Hi!  I am having a problem importing all the columns from a CSV file in SAS Studio using Proc Import.  There are a total of 24 columns.  The first 15 columns import ok but the other column headings are ignored.  Data is associated to the wrong columns afterwards.  Below is an example of the code and tthe column headings being imported.  

 

proc import datafile="/folders/myfolders/Files/CNT_tblContactV2.csv"
dbms=csv
out=contacts
replace;
GETNAMES=YES;

 

Below are the column headings from the CSV file.  The last column the program imports is MailingAddress.  The rest of the columns beginning with PrimaryPhone are not included in the input statement automatically created with the Proc Import statement.

 

ContactIDLastNameFirstNameCompanyMailingNameCountryMailingAddressLine1MailingAddressLine2MailingAddressLine3MailingAddressLine4MailingCityMailingStateMailingZipMailingZip4MailingAddressPrimaryPhone

 

It doesn't appear that there are any special characters that might cause a problem in the first row.  I am not sure how to resolve this issue.

 

Thanks in advance for any suggestions!

 

 

 

1 REPLY 1
Tom
Super User Tom
Super User

A line of a CSV file would not look like the tabular thing you posted.  It would look like this instead:

ContactID,LastName,FirstName,Company,MailingName,Country,MailingAddressLine1,MailingAddressLine2,MailingAddressLine3,MailingAddressLine4,MailingCity,MailingState,MailingZip,MailingZip4,MailingAddress,PrimaryPhone

Either your file is using TAB and not COMMA as the delimiter and when you pasted in the tabs the forum editor thought you wanted to make a table.   If so then just add the DELIMITER statement to your PROC IMPORT code.

delimiter='09'x;

Or more likely you have accidentally allowed Excel (or some other spreadsheet program) to open the file instead of opening it with a TEXT editor that will show you what the file actually looks like.  Perhaps the delimiter is a semi-colon or something else.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 1 reply
  • 2302 views
  • 0 likes
  • 2 in conversation