BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Vimal08
Obsidian | Level 7
Hi Team, I have a column where output is a string that looks like a path (/home/sas/demo/data). But the value is getting wrapped and the output is coming like this: /home/sas/ demo/data Please help me, how I can unwrap this string in the output? and get the desire output (/home/sas/demo/data). Your help will be highly appreciated.
1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

Try the COMPRESS() function with the S modifier. However, if you have spaces in the path those will also disappear. 

 

var = compress(var, , 's');

 

If you need to remove only carriage returns you can try the following where '0x0D'x is the hex code for a carriage return/line wrap.

 

var_clean = compress(var, '0x0D'x)

@Vimal08 wrote:
Hi Team, I have a column where output is a string that looks like a path (/home/sas/demo/data). But the value is getting wrapped and the output is coming like this: /home/sas/ demo/data Please help me, how I can unwrap this string in the output? and get the desire output (/home/sas/demo/data). Your help will be highly appreciated.

 

View solution in original post

6 REPLIES 6
Tom
Super User Tom
Super User

@Vimal08 wrote:
Hi Team, I have a column where output is a string that looks like a path (/home/sas/demo/data). But the value is getting wrapped and the output is coming like this: /home/sas/ demo/data Please help me, how I can unwrap this string in the output? and get the desire output (/home/sas/demo/data). Your help will be highly appreciated.

What output?  What procedure produced the output?  What type of destination did you use?

Can you create a simplified example that exhibits the issue?

Either include that data in your example as a SAS data step.  Or use one of the existing SASHELP datasets to demonstrate the issue.

Reeza
Super User

Try the COMPRESS() function with the S modifier. However, if you have spaces in the path those will also disappear. 

 

var = compress(var, , 's');

 

If you need to remove only carriage returns you can try the following where '0x0D'x is the hex code for a carriage return/line wrap.

 

var_clean = compress(var, '0x0D'x)

@Vimal08 wrote:
Hi Team, I have a column where output is a string that looks like a path (/home/sas/demo/data). But the value is getting wrapped and the output is coming like this: /home/sas/ demo/data Please help me, how I can unwrap this string in the output? and get the desire output (/home/sas/demo/data). Your help will be highly appreciated.

 

Vimal08
Obsidian | Level 7

Thank you. It worked.

Ksharp
Super User
Reeza,

var_clean = compress(var, '0x0D'x)
could wrote as
var_clean = compress(var, '0D'x)
?
Reeza
Super User
Yes, appears that also works 🙂

Tom
Super User Tom
Super User
23   data _null_;
24     c1 = '0D'x;
25     c2 = '0x0D'x ;
ERROR: Invalid hexadecimal constant string '0x0D'x.
26     put (c1 c2) (=$hex.);
27   run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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