The source code does not manipulate data from SAS tables or external files. It operates solely on a literal character string passed as an argument to a macro. Therefore, there are no dependencies on SASHELP data or unmanaged external data.
1 Code Block
MACRO DEFINITION
Explanation : This block defines the `name` macro. It takes a `fullname` argument. Inside, it uses `%SCAN` to extract the second and first parts of the `fullname` string (corresponding respectively to the first name and last name if the format is 'Last Name, First Name'). Then, it assembles these parts in 'first name last name' order and stores the result in the `newname` macro variable. Finally, the value of `newname` is written to the SAS log.
Explanation : This block calls the previously defined `name` macro. The string 'O'Malley, George' is passed as the `fullname` argument. The use of `%str()` is crucial here to mask the comma and apostrophe, so they are treated as literal characters of the string rather than as macro parameter delimiters or special characters by the SAS macro preprocessor. The result displayed in the log will be 'George O'Malley'.
Copied!
%name(%str(O%'Malley, George))
1
%name(%str(O%'Malley, George))
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.