Hello,
I'd like to separate alphanumeric string into numeric and character variables like below:
Data have:
Data want - how do I get the output like this:
I really appreciate your help!
Thank you!
or
data want;
set have;
num = input(text, ?? 8.);
if missing(num) then char = text;
run;
Try this
data have;
input text $20.;
datalines;
2.2
10
15
not reported
missing
<5
12.4
;
data want;
set have;
if input(text, 8.) then num = input(text, 8.);
else char = text;
run;
or
data want;
set have;
num = input(text, ?? 8.);
if missing(num) then char = text;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.