🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 07-16-2008 05:54 PM
(101505 views)
Seems like there should be an easy enough solution for this...I have just had difficulting thinking of the words to find that solution.
Example: I'd like to take the class list below and extract the numeric values from the string variables.
MATH400
BUS450
SCI310a
SCI310b
HIST299
Output
400
450
310
310
299
Is there an easy way to do this?
Thanks.
Example: I'd like to take the class list below and extract the numeric values from the string variables.
MATH400
BUS450
SCI310a
SCI310b
HIST299
Output
400
450
310
310
299
Is there an easy way to do this?
Thanks.
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In a DATA step, use the COMPRESS function in a SAS variable assignment statement to eliminate the non-numeric characters, and use UPCASE to convert lower to uppercase to reduce the list of variables specified in the COMPRESS function argument list.
Scott Barry
SBBWorks, Inc.
Scott Barry
SBBWorks, Inc.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In a DATA step, use the COMPRESS function in a SAS variable assignment statement to eliminate the non-numeric characters, and use UPCASE to convert lower to uppercase to reduce the list of variables specified in the COMPRESS function argument list.
Scott Barry
SBBWorks, Inc.
Scott Barry
SBBWorks, Inc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That works great. I just used
CourseNum = compress(CourseCode, ' ', 'A')
The third parameter, 'A' gets rid of all (A-Z) and (a-z) ...while the second parameter, ' ', does nothing other than hold space for the third parameter.
Thanks a ton.
Johnny
CourseNum = compress(CourseCode, ' ', 'A')
The third parameter, 'A' gets rid of all (A-Z) and (a-z) ...while the second parameter, ' ', does nothing other than hold space for the third parameter.
Thanks a ton.
Johnny
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Can I do the same in the JMP Formula editor? Extract a number from a string that is.