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;
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!
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.