BookmarkSubscribeRSS Feed
Pukkapies
Calcite | Level 5

Hi,

I'm trying to import a CSV file which is pipe delimited.

I am having trouble when it comes to the text field, for some reason SAS appears to treat new lines as a new record.

I have tried multiple options on the infile statement but I'm having no luck.

The text data is from an email therefore there are multiple lines and can have multiple characters (thankfully no pipes).

 

The code I'm using is:

 

data mailmessage;

infile "\\filename.csv" dsd dlm='|'

Encoding="utf-8" missover firstobs=2 lrecl=32767 n=5 TERMSTR=CR recfrm=N;

input

MsgId :$10.

priority :$3.

Status :$3.

IncidentID :$10.

CustEmailId :$10.

DateRecv :$50.

DateSent :$50.

MsgFrom :$50.

MsgTo :$256.

MsgSubject :$256.

MsgCategories :$90.

MsgBody :$Char10000.

AgentID :$5.

Msgtype :$3.

firstmsgdate :$50.

Lastmsgdate :$50.

Nummessages :4.

Numreplies :4.

loginname :$7.

custaccount :$20.;

run;

 

1 REPLY 1
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This has come up a few times before, try this post for example:

https://communities.sas.com/t5/Base-SAS-Programming/Read-CSV-file-with-embedded-CRLF/td-p/183296

Also, please dont refer to that as a Comma Separated Variable file as its not, its a delimited file.

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
  • 1 reply
  • 786 views
  • 1 like
  • 2 in conversation