SAS Substr From Right and Left Application Tutorial

Ermin Dedic MDC
27 Apr 202005:26

Summary

TLDRThis video demonstrates how to use the SUBSTR function in SAS, explaining both the right-hand and left-hand applications of the function. The right-hand application extracts specific parts of a string, such as selecting the 'May 16' portion from '06 May 16'. The left-hand application, on the other hand, modifies a string, as shown by changing '16' to '20' in '06 May 16'. Through clear examples and a step-by-step approach, the video helps users understand the practical usage of SUBSTR in data manipulation, making it easier to work with strings in SAS.

Takeaways

  • 😀 The video demonstrates how to use the SUBSTR function in SAS, focusing on both right-hand and left-hand applications.
  • 😀 The SUBSTR function in SAS takes three arguments: the variable name, the starting position, and the length of the substring.
  • 😀 The right-hand application of the SUBSTR function extracts a portion of a string without modifying the original string.
  • 😀 In the right-hand application, the first argument specifies the variable, the second argument defines where to start, and the third defines the length of the substring.
  • 😀 The example in the video uses a string '06 May 16', where the function starts at the 3rd position and extracts 'May 16'.
  • 😀 The left-hand application of the SUBSTR function modifies the original string by replacing part of it with a new value.
  • 😀 In the left-hand application, the function is positioned on the left of the equal sign, indicating that the string will be altered.
  • 😀 The left-hand application example in the video replaces '06 May 16' with '06 May 20'.
  • 😀 The left-hand application involves specifying the starting position and the length of characters to be replaced with new values.
  • 😀 Understanding the difference between right-hand and left-hand applications of SUBSTR helps in determining whether you're extracting or modifying parts of a string.
  • 😀 The video encourages viewers to experiment with both applications of the SUBSTR function in SAS for string manipulation tasks.

Q & A

  • What is the purpose of the SUBSTR function in SAS?

    -The SUBSTR function in SAS is used to extract a substring from a given string based on specified starting position and length.

  • What are the three arguments required by the SUBSTR function?

    -The SUBSTR function requires three arguments: the variable name, the starting position from which to begin extraction, and the length of the substring to extract.

  • In the right-side application of SUBSTR, what does the function do?

    -In the right-side application, the SUBSTR function extracts a portion of a string starting from a given position and for a specified length without modifying the original string.

  • How does the left-side application of SUBSTR differ from the right-side application?

    -In the left-side application, the SUBSTR function is used to modify a string by extracting a portion of the string and replacing part of it with the extracted substring.

  • In the example, what string is being worked with in the data step?

    -In the example, the string '06 May 16' is being used in the data step.

  • Why was the position '3' chosen in the first SUBSTR function example?

    -Position '3' was chosen to start extraction from the character 'M' in the string '06 May 16', effectively skipping the first two characters '0' and '6'.

  • What would the result be if the position was set to 2 instead of 3 in the first SUBSTR function example?

    -If the position were set to 2, the function would begin extraction from the '6' character, resulting in '6 May 16' as the substring.

  • Why is the number '5' used as the length argument in the right-side SUBSTR example?

    -The number '5' is used as the length to extract five characters starting from the 'M', so the result would be 'May 16'.

  • What does the 'equal sign' signify in the left-side application of SUBSTR?

    -In the left-side application, the 'equal sign' indicates that the extracted substring is being assigned to a variable, effectively modifying the original string.

  • How does the left-side application of SUBSTR change the original string in the example?

    -In the left-side application, the SUBSTR function changes the '06 May 16' string by replacing the '16' with '20', resulting in '06 May 20'.

Outlines

plate

Dieser Bereich ist nur für Premium-Benutzer verfügbar. Bitte führen Sie ein Upgrade durch, um auf diesen Abschnitt zuzugreifen.

Upgrade durchführen

Mindmap

plate

Dieser Bereich ist nur für Premium-Benutzer verfügbar. Bitte führen Sie ein Upgrade durch, um auf diesen Abschnitt zuzugreifen.

Upgrade durchführen

Keywords

plate

Dieser Bereich ist nur für Premium-Benutzer verfügbar. Bitte führen Sie ein Upgrade durch, um auf diesen Abschnitt zuzugreifen.

Upgrade durchführen

Highlights

plate

Dieser Bereich ist nur für Premium-Benutzer verfügbar. Bitte führen Sie ein Upgrade durch, um auf diesen Abschnitt zuzugreifen.

Upgrade durchführen

Transcripts

plate

Dieser Bereich ist nur für Premium-Benutzer verfügbar. Bitte führen Sie ein Upgrade durch, um auf diesen Abschnitt zuzugreifen.

Upgrade durchführen
Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
SAS TutorialSUBSTR FunctionString ManipulationData ScienceProgramming GuideRight ApplicationLeft ApplicationData StepVariable ExtractionCoding ExampleSAS Tips
Benötigen Sie eine Zusammenfassung auf Englisch?