Data is created directly within the script via the DATALINES instruction. A single observation is defined with the variables ID and original_phrase.
1 Code Block
DATA STEP Data
Explanation : This DATA step block creates the `phrase` table. It reads `ID` (numeric) and `original_phrase` (character) data from `DATALINES`. The line `better_phrase = TRANWRD(original_phrase, 'cat', 'dog');` uses the TRANWRD() function to search for and replace all occurrences of 'cat' with 'dog' in `original_phrase` and stores the result in the new variable `better_phrase`.
Copied!
DATA phrase;
INPUT ID original_phrase $ 2-50;
better_phrase = TRANWRD(original_phrase, 'cat', 'dog');
DATALINES;
1 A cat is the best pet ever, I love my cat.
;
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.