The doc is your friend. Here is a link to the SUBSTR doc.
Insert a put _all_; statement
Run the program.
Examine log.
The doc is your friend. Here is a link to the SUBSTR doc.
I think you want to declare String to be a CHARACTER variable. Currently, it is a numeric variable. To declare a character variable, put a '$' symbol after the name of the variable on the INPUT statement, like this:
Input string $ 7.;
After making that change, rerun the program and examine the output. Let us know if you still have questions!
What determines `pos`? Please provide some example data.
@PurushReddy wrote:
flow of work
Last _word=Substr(string,7-pos+2);
*7-pos+2(here pos value:4)*
What is your question?
Your task can be much easier solved by using the right tool (Maxim 14), which is the SCAN function:
data a;
input string $7.;
last_word = scan(string,-1,"., ");
cards;
ABC.DEF
JHG GHTY
HYT,XYZ
;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: