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
;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.