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

I've a data like below. Here I need to remove only the colon (:) in the variable 'userid' if it is a first character.

userid
:sassrv
:datapo@saspw
74064:datapo@saspw

I need the data as below.

userid
sassrv
datapo@saspw
74064:datapo@saspw

I tried with compress function to achieve this, but could not succeed. Please advise,

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Code: Program

data have;
input userid $40.;
cards;
:sassrv
:datapo@saspw
74064:datapo@saspw
;
run;
data want;
set have;
new=prxchange('s/^://',1,userid);
run;

View solution in original post

4 REPLIES 4
LinusH
Tourmaline | Level 20

Why didn't it work with compress?

You need to use it in conjunction with if, substr and cats.

Data never sleeps
Babloo
Rhodochrosite | Level 12

Thanks for your response.

May I request to give a code snippet as I was doing something wrong with these function.

Ksharp
Super User

Code: Program

data have;
input userid $40.;
cards;
:sassrv
:datapo@saspw
74064:datapo@saspw
;
run;
data want;
set have;
new=prxchange('s/^://',1,userid);
run;
MadhuKorni
Quartz | Level 8

data log_analysis;

infile '/usr/sas/sas_config/Lev1/SASApp/Logs/SASApp_STP_2015-08-19_tmp1_19142.log' truncover;

input var : $ 3000.;

var1 = _infile_;

if var1 = :'2015';

Date_With_TimeStamp = scan(var1,1," ");

Status = scan(var1,2," ");

Processid = scan(var1,3," ");

if substr(scan(var1,4," "),1,1)=':' then userid =substr(scan(var1,4," "),2) ;

else userid = scan(var1,4," ");

Details = scan(var1,-1,'-');

drop var var1;

run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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