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