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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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