BookmarkSubscribeRSS Feed
sreeram
Fluorite | Level 6
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
2 REPLIES 2
sreeram
Fluorite | Level 6
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);
SPR
Quartz | Level 8 SPR
Quartz | Level 8
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

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1350 views
  • 0 likes
  • 2 in conversation