If data contains only digits or digits with decimals then would like to create a column "want" and assign those records to the column. tried compress function but it is compressing decimals too.
Rawdata
UNKNOWN
37.5/25
37.5-25
0.25
25
10
1000IU
Rawdata want
UNKNOWN
37.5/25
0.25 0.25
25 25
10 10
1000IU
This should do it:
want = input(rawdata, ??16.);
Since you didn't specify, this approach assumes you would like the new variable to be numeric, not character.
Yes want is only Numeric an would like want_char with remaining values
If you would like to add WANT_CHAR as well, it's easy enough:
want = input(rawdata, ??16.);
if want = . then want_char = rawdata;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.