BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
SannaSanna
Quartz | Level 8


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
1 ACCEPTED SOLUTION

Accepted Solutions
slchen
Lapis Lazuli | Level 10

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

View solution in original post

2 REPLIES 2
slchen
Lapis Lazuli | Level 10

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

stat_sas
Ammonite | Level 13

data want;

set have;

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

run;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 784 views
  • 3 likes
  • 3 in conversation