BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
hanahch
Calcite | Level 5

Hello,

 

I'd like to separate alphanumeric string into numeric and character variables like below:

 

Data have:

hanahch_0-1661144183848.png

 

Data want - how do I get the output like this:

hanahch_1-1661144245644.png

 

I really appreciate your help!

Thank you!

 

1 ACCEPTED SOLUTION

Accepted Solutions
andreas_lds
Jade | Level 19

or

data want;
   set have;
   num = input(text, ?? 8.);
   if missing(num) then char = text;
run;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

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;
andreas_lds
Jade | Level 19

or

data want;
   set have;
   num = input(text, ?? 8.);
   if missing(num) then char = text;
run;
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
  • 2 replies
  • 967 views
  • 0 likes
  • 3 in conversation