BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Emma2021
Quartz | Level 8
I have a numeric integer variable. If last 2 digits are zeros, then I want to remove those zeros. How can I do that?
For example, 100 should be 1, 101 should be 101, 3300 should be 33.
Thank you!
1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12

How about this?

data have;
  do num=100, 101, 3300;
    output;
  end;
run;

data want;
  set have;
  temp=mod(num,100);
  new=ifn(temp=0,num/100,num);
  drop temp;
run;

/* If you want to store the result in the same variable again, the following data step is simpler. */
data want;
  set have;
  if mod(num,100)=0 then num=num/100;
run;

View solution in original post

1 REPLY 1
japelin
Rhodochrosite | Level 12

How about this?

data have;
  do num=100, 101, 3300;
    output;
  end;
run;

data want;
  set have;
  temp=mod(num,100);
  new=ifn(temp=0,num/100,num);
  drop temp;
run;

/* If you want to store the result in the same variable again, the following data step is simpler. */
data want;
  set have;
  if mod(num,100)=0 then num=num/100;
run;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1 reply
  • 633 views
  • 1 like
  • 2 in conversation