BookmarkSubscribeRSS Feed
Pnong
Calcite | Level 5

Hi All,

 

Which codes to use to address the problem  where the decription appears in the next cell? I wish to turn the informaiton which has over 5000 rows into a table .For example:t changing  the Table 1  which is csv format  to Table 2

Table 1 Csv format

85415900,"Other semiconductor devices, other than semiconductor-based transducers, other
than photosensitive devices, nesoi"     

 Table 2

HS codeDescription
85415900Other semiconductor devices, other than semiconductor-based transducers, otherthan photosensitive devices, nesoi".
2 REPLIES 2
Kathryn_SAS
SAS Employee

You may have an embedded carriage return in your quoted string. You can try the following:

https://support.sas.com/kb/26/065.html

 

 

Tom
Super User Tom
Super User

From the description is looks like the CSV file has end-of-line characters in the value of one of the fields.

 

If you are lucky it only has CR or LF in the field value and uses CR-LF as the end-of-line marker.

Try reading the file using the TERMSTR=CRLF option on the INFILE (or FILENAME) statement.

 

If the fields contain the same characters as used for the end-of-line markers then you will need to preprocess the file.  Since it looks like the field with the end-of-line marker is quoted you can use something that counts the number of quotes on a line to detect and remove or replace them.

 

Try this macro to make a copy of the CSV file with the embedded CR and LF characters replaced (or removed):

https://github.com/sasutils/macros/blob/master/replace_crlf.sas

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 379 views
  • 0 likes
  • 3 in conversation