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

Hi ,

 

new to SAS

 

I have data where i need to extract the % without the "%"

 

Data (character values):
column 1

11(21.2%)

0(0.0%)

9(17.3%)

5.(9.6%)

 

want (in numeric values):

column2

21.2

0.0

17.3

9.6

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

You identified the proper tool for the job.  Try:

 

column_2 = scan(column_1, 1, '(' );

View solution in original post

2 REPLIES 2
Astounding
PROC Star

You identified the proper tool for the job.  Try:

 

column_2 = scan(column_1, 1, '(' );
ballardw
Super User

Scan will return the Character value, so you will need to use an input.

The question, since you are starting with a percent is do you actually want a Percent value: i.e. 21.2% = 0.212 as decimal or 100*0.212 or 21.2

 

Either of the Y or Z yields 21.2 for the first.

data junk;
  x="11(21.2%)";
  y= input(scan(x,2,'(%)'),6.);
  z= input(scan(x,2,'()'),comma6.);
run;

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 25. 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
  • 519 views
  • 0 likes
  • 3 in conversation