BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

 If the maximum number you actually have is smaller than the maximum possible integer that SAS can represent exactly;

586   data _null_;
587     x=constant('exactint');
588     put x= comma23.;
589   run;

x=9,007,199,254,740,992

Then you can just read the digits into a number and put it back out as a string.

id1=put(input(substr(id,4),20.),20.-l);

But if you really have 20 decimal digits then that is too long to put into a number.  So instead using the VERIFY() funciton to find the location of the first non-zero digit.  Let's try both for some dummy data.

data want;
  input id $23.;
  id2=substr(id,4);
  if verify(trim(id2),'0') then id2=substr(id2,verify(id2,'0'));
  else id2='0';
  id3=put(input(substr(id,4),20.),20.-l);
  match=(id2=id3);
cards;
ABC00000012360948952321
ABC00000000000948902321
ABC00000000025369214558
ABC00000000000000000000
ABC12345678901234567890
;

 image.png

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
  • 15 replies
  • 1749 views
  • 10 likes
  • 6 in conversation