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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.