BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ArchanaSudhir
Obsidian | Level 7

HI,

 

I have a set of data with percentages.

TotalC is a character variable.

 

TotalC

222,98

1,0.3

2,45

13,45

 

 

I need to extract only the part of string before , (210,1,2,13).

 

I need a numeric variable total:

 

Total

210

1

2

13

 

Please advise.

 

Thanks,

Archana

1 ACCEPTED SOLUTION

Accepted Solutions
2 REPLIES 2
ballardw
Super User

Where does the 210 come in? Did you mean the part before the comma:

 

A character variable could be:

 

 

Newvariable = scan(TotalC,1,',');

in a data step.

 

If you need more than before only the first comma then you will need to provide rules.

 

If there is no part before the comma what should the returned value be?

PGStats
Opal | Level 21

total = input(scan(totalc,1,","), best.);

PG

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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