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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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