The two faces of the SUBSTR function | The SAS Reference
Define a new variable x characters beholder from another variable. Substitute in a text variable, x characters from the z th. These two different major themes are treated with the same function SUBSTR. According to it is placed to the left or right of equality, the function beholder serves a different need.
1. Create a new variable from a subset of another: the most common application of the SUBSTR function is to keep a subset of a string, referring to its position start and length, to define a new variable.
Notation: The function has three parameters the name of the original variable, the position of the first character we are interested beholder in the total number of characters from the starting point (optional).
Example: In the following beholder example, consider a variable TESTCASE. The tc0101 tests, tc0102 belong to the same group, while tc0201 belongs to a different group. The first two digits refer to the group. To save these numbers in a variable GRP, the SUBSTR function is used.
Note: If the number of characters to be used is not specified beholder by a third parameter, the rest of the string from the second parameter data which is stored position.
2. Replace part of a string: to update a variable in a data step, the process is tedious beholder in SAS. In one case, however, it can be avoided: change a subset of a text variable defined by its position in the string and its length.
Recall, update a variable in a data step: first, the variable is renamed. This variable contains the original values, which interest us. We can define a new variable with the original name because it no longer exists beholder name. This new variable will take our original values, more appropriate beholder via a new addition, a concatenation or another.
Example: Returning to the example of the first section with our variable TESTCASE. The string 'tc' starting at position 1 and 2 long is replaced by the characters 'AB'.
Note that the substitution value must be the same length. If it is larger, the characters will be ignored. If it is smaller, white replace beholder missing gaps. In addition, you can not substitute that of the existing characters, white start and end of string included.
Posted in Database, Data Management, Features, The fontions, beholder For Steps, By Level Certification For levels per theme, SAS beginner, beholder substr | Tagged update, function, replace, SAS, replace, substring, variable | 5 comments
This site is a godsend for me, I started SAS 9 this week ... The writing is clear, the clear explanations, the perfect graphics and humorous pictures. Brief "What happiness! "
I have a digital channel, (12345678), and I just want to have the first three positions (123). The SUBSTR function does not work. Can you help me? Thank you by Nassim March 20, 2011 at 6:43
Notify me by email when new comments.
Home Menu Select Category Boutique (15) Software and Hardware (4) SAS English beholder (5) French SAS (5) ZZ - Work (3) Community (62) Events (29) Interviews (7) Non-SAS Solutions beholder (5) SAS Solutions (3) Web English (6) Web French (4) Saturday jobs (75) Office (18) Tips for Applying (11) Business Establishments (6) Training Institutions (12) Publication Announcements (15) Publication profiles (15 ) Exos (37) fontions (56) bquote% (1)% eval (3)% let (1)% nbrquote (1) qsysfunc% (1)% str () (1) sysevalf% (1)% sysfunc ( 6)% upcase (1) abs (1) attrn (1) byte (2)
Define a new variable x characters beholder from another variable. Substitute in a text variable, x characters from the z th. These two different major themes are treated with the same function SUBSTR. According to it is placed to the left or right of equality, the function beholder serves a different need.
1. Create a new variable from a subset of another: the most common application of the SUBSTR function is to keep a subset of a string, referring to its position start and length, to define a new variable.
Notation: The function has three parameters the name of the original variable, the position of the first character we are interested beholder in the total number of characters from the starting point (optional).
Example: In the following beholder example, consider a variable TESTCASE. The tc0101 tests, tc0102 belong to the same group, while tc0201 belongs to a different group. The first two digits refer to the group. To save these numbers in a variable GRP, the SUBSTR function is used.
Note: If the number of characters to be used is not specified beholder by a third parameter, the rest of the string from the second parameter data which is stored position.
2. Replace part of a string: to update a variable in a data step, the process is tedious beholder in SAS. In one case, however, it can be avoided: change a subset of a text variable defined by its position in the string and its length.
Recall, update a variable in a data step: first, the variable is renamed. This variable contains the original values, which interest us. We can define a new variable with the original name because it no longer exists beholder name. This new variable will take our original values, more appropriate beholder via a new addition, a concatenation or another.
Example: Returning to the example of the first section with our variable TESTCASE. The string 'tc' starting at position 1 and 2 long is replaced by the characters 'AB'.
Note that the substitution value must be the same length. If it is larger, the characters will be ignored. If it is smaller, white replace beholder missing gaps. In addition, you can not substitute that of the existing characters, white start and end of string included.
Posted in Database, Data Management, Features, The fontions, beholder For Steps, By Level Certification For levels per theme, SAS beginner, beholder substr | Tagged update, function, replace, SAS, replace, substring, variable | 5 comments
This site is a godsend for me, I started SAS 9 this week ... The writing is clear, the clear explanations, the perfect graphics and humorous pictures. Brief "What happiness! "
I have a digital channel, (12345678), and I just want to have the first three positions (123). The SUBSTR function does not work. Can you help me? Thank you by Nassim March 20, 2011 at 6:43
Notify me by email when new comments.
Home Menu Select Category Boutique (15) Software and Hardware (4) SAS English beholder (5) French SAS (5) ZZ - Work (3) Community (62) Events (29) Interviews (7) Non-SAS Solutions beholder (5) SAS Solutions (3) Web English (6) Web French (4) Saturday jobs (75) Office (18) Tips for Applying (11) Business Establishments (6) Training Institutions (12) Publication Announcements (15) Publication profiles (15 ) Exos (37) fontions (56) bquote% (1)% eval (3)% let (1)% nbrquote (1) qsysfunc% (1)% str () (1) sysevalf% (1)% sysfunc ( 6)% upcase (1) abs (1) attrn (1) byte (2)
No comments:
Post a Comment