Help using Base SAS procedures

dashes and spaces

Accepted Solution Solved
Reply
Contributor
Posts: 61
Accepted Solution

dashes and spaces


Hello-

Looking for some assistance in putting together a new string variable.  Due to bad data entry from various sources, I need to somehow make the data element consistent.   Currently I have data sample #1- under column heading 'p_ds' there are dashes and spaces within the character string.  I would like to create a new variable that would 1) eliminate the dash '-' in obs 1, 2 and 4. and 2) eliminate the space in position 3 and position 9 in obs 5.

obsp_dscount
101-100017-60020005
201-61143609021125
341595123684248
40461549-60033623
505 61564 60034208

I would like my final dataset to look like sample #2.  How can I best approach this?

1110001760020005
2161143609021125
341595123684248
4046154960033623
556156460034208

Accepted Solutions
Solution
‎07-28-2014 04:57 PM
Super Contributor
Posts: 275

Re: dashes and spaces

Posted in reply to Suzanne_Ed

string=compress(p_ds,,'kd');

View solution in original post


All Replies
Solution
‎07-28-2014 04:57 PM
Super Contributor
Posts: 275

Re: dashes and spaces

Posted in reply to Suzanne_Ed

string=compress(p_ds,,'kd');

Trusted Advisor
Posts: 1,228

Re: dashes and spaces

Posted in reply to Suzanne_Ed

data want;

set have;

p_ds=compress(p_ds,,'kd');

run;

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 185 views
  • 3 likes
  • 3 in conversation