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;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 289 views
  • 1 like
  • 2 in conversation