Statistical Analysis System (SAS) Programming Certification Practice Exam

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

Prepare for the SAS Programming Certification Exam with our comprehensive quiz. Study with multiple-choice questions, detailed explanations, and helpful hints to boost your confidence. Ace your certification test!

Each practice test/flash card set has 50 randomly selected questions from a bank of over 500. You'll get a new set of questions each time!

Practice this question and more.


What is the proper way to create a FullName variable concatenating FirstName and LastName without extra spaces?

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

  2. fullname=firstname||lastname;

  3. fullname=trim(firstname||lastname);

  4. fullname=firstname||' '||lastname;

The correct answer is: fullname=trim(firstname)||' '||trim(lastname);

To create a FullName variable that concatenates FirstName and LastName without any extra spaces, the correct approach involves ensuring that any leading or trailing spaces from both FirstName and LastName are removed before concatenation. Using the trim function on both FirstName and LastName, followed by concatenation with a single space in between, precisely addresses this requirement. This method guarantees that if either FirstName or LastName contains unexpected spaces, they will not affect the final concatenated output. In the context of the other choices, some do not effectively handle potential unwanted spaces. For example, concatenating FirstName and LastName directly without trimming would retain any extra spaces, resulting in incorrect formatting. Similarly, improperly applying the trim function to the concatenated result would not address any unwanted spaces that may exist at the ends of the individual names before they are combined. Thus, the combination of trimming both names first, followed by properly placing a space in between, makes the chosen option the best practice for this scenario.