SAS Studio

Write and run SAS programs in your web browser
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RebeccaJW
Calcite | Level 5

Hello,

 

I am asked to subtract the numeric portion of a character variable using input(), substrn() or scan(). 

 

Thank you in advance for your help!

 

This is what the original character look like.This is what the original character look like.This is the expected result.This is the expected result.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

How do those align? How does 10.5[1] become 15.7 or is that just a generic example?

 

If you're just trying to remove the [1] section, use SCAN and INPUT.

 

num_var = input(scan(char_var, 1, "[]"), best32.);

@RebeccaJW wrote:

Hello,

 

I am asked to subtract the numeric portion of a character variable using input(), substrn() or scan(). 

 

Thank you in advance for your help!

 

This is what the original character look like.This is what the original character look like.This is the expected result.This is the expected result.

 


 

View solution in original post

3 REPLIES 3
Tom
Super User Tom
Super User

Subtract them from what?

Show your actual data, not photographs of your data.

Show what you have tried. 

Reeza
Super User

How do those align? How does 10.5[1] become 15.7 or is that just a generic example?

 

If you're just trying to remove the [1] section, use SCAN and INPUT.

 

num_var = input(scan(char_var, 1, "[]"), best32.);

@RebeccaJW wrote:

Hello,

 

I am asked to subtract the numeric portion of a character variable using input(), substrn() or scan(). 

 

Thank you in advance for your help!

 

This is what the original character look like.This is what the original character look like.This is the expected result.This is the expected result.

 


 

RebeccaJW
Calcite | Level 5
Thank you so much! It works!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 3 replies
  • 2472 views
  • 2 likes
  • 3 in conversation