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;

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 488 views
  • 0 likes
  • 3 in conversation