BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Franknferter
Fluorite | Level 6

I am new to SAS and have only been using it for 3 months. I am using Enterprise Guide 7.1. 

 

I am trying to split a column that contains character data displayed as SP0000001 to SP1234567. I would like to eliminate the SP at the beginning leaving just the numbers without the zeros in the front.

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Welcome to the SAS Community 🙂

 

Provided that you want the result to be a numeric variable you can do like this

 

data have;
input string :$9.;
datalines;
SP0000001
SP1234567
;

data want;
	set have;
	num=input(compress(string, '', 'kd'), best.);
run;

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26
newvar = input(substr(varname,3),8.);
--
Paige Miller
PeterClemmensen
Tourmaline | Level 20

Welcome to the SAS Community 🙂

 

Provided that you want the result to be a numeric variable you can do like this

 

data have;
input string :$9.;
datalines;
SP0000001
SP1234567
;

data want;
	set have;
	num=input(compress(string, '', 'kd'), best.);
run;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 743 views
  • 0 likes
  • 3 in conversation