Here is a useful function for you. The SCAN function. Scan allows you to isolate a word ( or group of letters ) in a text string given a definable set of delimiters. Here is an example.
string='Here is my string';
first_word=scan( string, 1, ' ' ); **First word in a string;
last_word=scan( string, -1, ' ' ); **Last word in a string;
Keep in mind that a word is simply defined as a group of letters between two delimiters. So you can scan strings using various tricks.
string='Hello SAS community people';
beginning= scan( string, 1, 'S' ); ** returns "Hello ";
middle = scan( string, 2, 'S' ); ** returns "A";
end= scan( string, 3, 'S' ); **returns " community people";
AFHood Analytics Group has consultants on staff to help with your SAS scripts. We can work with you on a small fix or a large development projects. Contact us to discuss how we can work together.