SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Walternate
Obsidian | Level 7

Hi,

 

I have some files which I read in from Excel. 

 

There are some long strings which have carriage returns in the middle. I need to remove the CR but leave the rest of the value intact. Is this possible?

 

Thanks!

1 ACCEPTED SOLUTION
7 REPLIES 7
Walternate
Obsidian | Level 7

I tried the following:

 

directory3 = compress(directory2, '0d'x);

 

I did not get an error message but the carriage returns are still there. Did I miss some punctuation or a modifier or something?

ErikLund_Jensen
Rhodochrosite | Level 12

hi @Walternate 

 

You could try removing '0A'x (the line feed char) also. Might solve your problem.

Reeza
Super User

Use a HEX format on your character string to see the character in the string.

 

proc print data=have;
var stringVar;
format stringVar $hex50.; *make sure there's an appropriate length;
run;
ballardw
Super User

I strongly suspect that you want to replace the character with a space. Removing the line feed means the resulting text will be poor for reading.

 

Example:

This is an Excel value
split to two or more
lines.

When you remove the line feeds you will get

This is an Excel valuesplit to two or morelines.

The TRANSLATE function will replace a character with another.

Walternate
Obsidian | Level 7

Is there any way to change my output program which built the Excel files so that it is only outputting text values and no weird characters? 

 

To output I am just using ods excel and proc printing a data file. 

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!

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
  • 7 replies
  • 3408 views
  • 4 likes
  • 6 in conversation