Statistical Analysis System (SAS) Programming Certification Practice Exam

Disable ads (and more) with a membership for a one time $4.99 payment

Question: 1 / 100

What method is best for removing extra blanks while concatenating FirstName and LastName into FullName?

fullname=trim(firstname)||' '||lastname;

fullname=trim(firstname)||' '||trim(lastname);

The best method for removing extra blanks while concatenating FirstName and LastName into FullName is to use the trim function on both FirstName and LastName before concatenation.

Using the trim function removes any trailing blanks from each string. By applying it to both FirstName and LastName individually, this approach ensures that any leading or trailing spaces in either name do not affect the final concatenation. When concatenated with a single space in between, this produces a FullName that has no extra spaces.

This method effectively handles the scenarios where either name might inadvertently contain excess spaces, delivering a neater, cleaner FullName result. Thus, the final output will only contain a single space between the two names, making it the most effective solution for the given scenario.

fullname=firstname||' '||lastname;

fullname=trim(firstname||' '||lastname);

Next

Report this question