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.
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;
newvar = input(substr(varname,3),8.);
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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Check out this tutorial series to learn how to build your own steps in SAS Studio.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.