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;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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