BookmarkSubscribeRSS Feed
Calcite | Level 5

When I am importing CSV file into SAS , Junk value is getting inserted in last coloumn of every record. Please let me know if there is any option which remove junk values while importing. I am using Infile statement with following Options


Rhodochrosite | Level 12
Looks like you are using the DATA step for the import.

Generally, this sort of thing is an indication of a problem in the incoming data stream. You will need to do some detective work. The first ones that I might look at are

-- do you have "junk" at the end of the incoming record? You should use a hex editor to look at the data line as there may be some non-display characters.
-- did the .CSV file come from a different environment? For instance, if it was created on a PC and you used a binary FTP transfer to get it to Unix, then the End-Of-Line character will be wrong and may cause errors. Ditto the other way.

Doc Muhlbaier
Rhodochrosite | Level 12
Doc will be right! As the junk is at the end of the last field, it will normally be part of the end-of-line string.
In SAS92 infile option TERMSTR= solves the problem (like termstr=crlf)
Before SAS92, just add the rogue character to the DLM= value
infile ghjfghj dsd dlm='3b0a0d'x ....etcetera... ;
(where 3b is the hex value for semi-colons on most platforms)
I added 0A0Dx among delimiters on an "all-inclusive" approach. If normally treated as line-end characters, then they won't arrive in the infile buffer, but when they do, they'll be excluded from data values.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 in conversation