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 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2395 views
  • 10 likes
  • 6 in conversation