The SAS Output Delivery System and reporting techniques

How do I separate one text variable into two numeric variables?

Reply
N/A
Posts: 0

How do I separate one text variable into two numeric variables?

My variable is blood pressure (BP). For example the value is text and looks like:
BP
136/80

How do I convert this variable into two separate numeric variables that look like:
systolic
136

diastolic
80

Thanks.
Super Contributor
Posts: 273

Re: How do I separate one text variable into two numeric variables?

here is a solution with the use of scan function to separate words
then i use another function to translate the numbers in characters into a numeric sas variable
i showed, as you not precise give the length of the char variable, two start variables with the same information

data a;
a=" 136/80 ";
b="136/80";
c=input(left(scan(a,1,"/")),best12.);
d=input(scan(b,2,"/"),3.);
put c= d=;
run;

Andre
N/A
Posts: 0

Re: How do I separate one text variable into two numeric variables?

good Message was edited by: Display name not found
N/A
Posts: 0

Re: How do I separate one text variable into two numeric variables?

Thanks for the info. I used your example to make my code work.
Ask a Question
Discussion stats
  • 3 replies
  • 141 views
  • 0 likes
  • 2 in conversation