Help using Base SAS procedures

Write a simple code to delete one zero from the below value.

Reply
Occasional Contributor
Posts: 6

Write a simple code to delete one zero from the below value.

i have variable with value, example: N01221-0123-0101. i just need the value as
N01221-123-0101. by deleting a zero from the right in the middle one (i.e 0123 to 123). can you write it Message was edited by: sreeram
Occasional Contributor
Posts: 6

Re: Write a simple code to delete one zero from the below value.

This below code is working thanks for your help GOD.

if substr(usubjid,6,1) = '0' then substr(usubjid,6,4)=substr(usubjid,7,3);
breaks=substr(usubjid,10,5);
usubjid=substr(usubjid,1,8)||strip(breaks);
Super Contributor
Super Contributor
Posts: 365

Re: Write a simple code to delete one zero from the below value.

Hello Sreeram,

How about this:
[pre]
data i;
s='N01221-0123-0101';
i=INDEX(s,'-');
r=SUBSTR(s,1,i)||SUBSTR(s,i+2);
run;
[/pre]
Sincerely,
SPR
Ask a Question
Discussion stats
  • 2 replies
  • 255 views
  • 0 likes
  • 2 in conversation