SAS Studio

Write and run SAS programs in your web browser
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-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 2919 views
  • 0 likes
  • 2 in conversation