BookmarkSubscribeRSS Feed
Avenue
Calcite | Level 5

Hi Guys,

I am trying to get the last 2 digits from a numeric field. Can you please assist:

If the value is 101234 then I want my output to be 34.

Thanks in advance.

4 REPLIES 4
user24feb
Barite | Level 11

You're looking for the modulo-function: mod(101234,100) gives 34.

Avenue
Calcite | Level 5

Works like a charm. Thanks.

aswadhama
Calcite | Level 5

Worked great.I wanted to get the output where the the numeric values in a column are not incremented by 100.Example:I want to see where the values are 150,192 etc.The valid values are only 100,200,300... etc. I used in proc sql as

and mod(a.XXXXX_AM,100)<>0 and worked great.

zahirraihan
Calcite | Level 5

Hi Avenue,

following code will assist you to resolve your problem:

DATA _null_;

  x1=101234;

  x2=INPUT(SUBSTR(PUT(x1,best.),LENGTH(PUT(x1,best.))-2+1),2.);

  PUT x2=;

RUN;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 4 replies
  • 27097 views
  • 4 likes
  • 4 in conversation