DATA Step, Macro, Functions and more

Substr statement

Accepted Solution Solved
Reply
Super Contributor
Posts: 319
Accepted Solution

Substr statement

Hi, all:

 

I found these codes written from previous programmer.   Is it the (1,length(indicator)-1) in IND and (length(indicator),1) in TYPE are the same?  Please help.  Thanks.

 

Y

 

IND=substr(INDICATOR,1,length(indicator)-1);

TYPE=substr(INDICATOR,length(indicator),1);  

 

 


Accepted Solutions
Solution
‎04-27-2016 07:37 PM
Respected Advisor
Posts: 4,919

Re: Substr statement

IND is the whole string except the last character

TYPE is the last character

PG

View solution in original post


All Replies
Solution
‎04-27-2016 07:37 PM
Respected Advisor
Posts: 4,919

Re: Substr statement

IND is the whole string except the last character

TYPE is the last character

PG
Super Contributor
Posts: 319

Re: Substr statement

I don't quite understand why TYPE is the last character.

Super Contributor
Posts: 319

Re: Substr statement

SUBSTR( ) Used on Right Side on Assignment Statement.

 
SYNTAX: 
=SUBSTR (char_string, start_position,no_of_chars_to_read );

 

extracts char string from start position and with length given. 
 
In that mean, TYPE is starting the whole length of "INDICATOR", and only extract the last number? right?
Respected Advisor
Posts: 4,919

Re: Substr statement

For example, "ybz12003" has length 8, so the string of length 1 starting at position 8 is "3".

PG
Super Contributor
Posts: 319

Re: Substr statement

Thanks

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 376 views
  • 0 likes
  • 2 in conversation