I am trying to extract the lower bounds of a 95% CI from a character string and I am trying to extract the number while making it numeric.
The character string I am extracting from is "95% C.I.: 7.7 - 10.7" I am trying to just keep the 7.7 and make it numeric.
The code I put in is:
countylowerCI = SUBSTR(SCAN(countyCI, 1, ':-'));
Does this help you figure it out?
data a; countyci="95% C.I.: 7.7 - 10.7"; word1=scan(countyCI, 1, ':-'); word2=scan(countyCI, 2, ':-'); word3=scan(countyCI, 3, ':-'); run;
The above code does not return a numeric value, it returns a character string, but I'm guessing you make that change after you figure it out.
Why are you getting confidence intervals as text strings? All SAS procedures can get the actual numerical value as output, that's a much better way to go.
As suggested, do this in stages. First scan the character string, confirming you have the right number (as a character string), then convert it using the INPUT function.
DATA CI; countyCI = "95% C.I.: 7.7 - 10.7"; countylowerCI_char = SCAN(countyCI, 2, ':-'); countylowerCI_num = input(countylowerCI_char,best10.); RUN;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
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.