Hi there! I have taxonomic data with the phyla through genus listed from microbiome 16s sequencing. I want to pull just the 'Family' name out of the string, but each character string is different due to the nature of each taxonomy identified within the sample.
I have included a screenshot of the character variable "taxon" that has this string information. It's a character variable with 106 length. (I cannot share the data in full so I hope the image is enough context). Is there an approach you'd recommend taking to pull out this substring from variable starting positions? I do have a delimiter of sorts - the " / ". The most efficient method would be useful as I have over 1 million records.
Thank you!
Try this. The SCAN function is finding the second word reading from the right:
data test;
string = 'w1/w2/w3/w4/w5/w6';
Family = scan(string,-2,'/');
put _all_;
run;
@lsandell wrote:
I want to pull just the 'Family' name out of the string, ...
What is the 'Family' name in the strings listed?
What is the substring you need as an outcome after parsing every taxon string?
Koen
Just one word from the whole string (what's in between the slashes). The target string is the name before the final forward slash (/) [i.e., second to last alphabetic portion].
So what is your business rule for identifying the family name in the string?
Thanks! It's the name before the final forward slash (/) [i.e., second to last alphabetic portion].
Try this. The SCAN function is finding the second word reading from the right:
data test;
string = 'w1/w2/w3/w4/w5/w6';
Family = scan(string,-2,'/');
put _all_;
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.
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.