Help using Base SAS procedures

data btw brackets

Accepted Solution Solved
Reply
Contributor
Posts: 21
Accepted Solution

data btw brackets

Hi All,

My data look like below format . I need col value in two variable , N & pct.

have:

id           col

100        239  ( 34.5)

101         67  (100.0)

103           0

104            8 (  6.9)

105        58   (     5.2)

want:

id           col                         n         pct

100        239    ( 34.5)        239      34.5

101         67  (100.0)           67       100.0

103           0                         0

104            8 (  6.9)              8        6.9

105         58  (    5.2)            58       5.2

Thanks

Cathy


Accepted Solutions
Solution
‎08-25-2015 11:23 PM
Super User
Posts: 17,831

Re: data btw brackets

Use the Scan function, but you might need or want to account for cases where it's 0.

n=scan(original_var, 1, "(");

pct=scan(original_var, 2, "(");

View solution in original post


All Replies
Solution
‎08-25-2015 11:23 PM
Super User
Posts: 17,831

Re: data btw brackets

Use the Scan function, but you might need or want to account for cases where it's 0.

n=scan(original_var, 1, "(");

pct=scan(original_var, 2, "(");

Contributor
Posts: 21

Re: data btw brackets

Thanks reeza!!!

but i tweaked little bit

pct=scan(original_var, 2, "()");

Thanks

Cathy

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 265 views
  • 0 likes
  • 2 in conversation