BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ybz12003
Rhodochrosite | Level 12

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);  

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

IND is the whole string except the last character

TYPE is the last character

PG

View solution in original post

5 REPLIES 5
PGStats
Opal | Level 21

IND is the whole string except the last character

TYPE is the last character

PG
ybz12003
Rhodochrosite | Level 12

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

ybz12003
Rhodochrosite | Level 12

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?
PGStats
Opal | Level 21

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

PG
ybz12003
Rhodochrosite | Level 12

Thanks

AI Navigator GIF.gif


Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.

Check it out on Microsoft Marketplace →

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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