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.
ContactID | LastName | FirstName | Company | MailingName | Country | MailingAddressLine1 | MailingAddressLine2 | MailingAddressLine3 | MailingAddressLine4 | MailingCity | MailingState | MailingZip | MailingZip4 | MailingAddress | PrimaryPhone |
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!
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.