SAS Base Certification – Question 3

Question 3: Given the text file COLORS.TXT:

----+----1----+----2----+----
RED    ORANGE  YELLOW  GREEN
BLUE   INDIGO  PURPLE  VIOLET
CYAN   WHITE   FUCSIA  BLACK
GRAY   BROWN   PINK    MAGENTA

The following SAS program is submitted:

1
2
3
4
5
data WORK.COLORS;
  infile 'COLORS.TXT';
  input @1 Var1 $ @8 Var2 $ @;
  input @1 Var3 $ @8 Var4 $ @;
run;

What will the data set WORK.COLORS contain?

Options:

A.	
Var1 Var2 Var3 Var4 ------ ------ ------ ------ RED ORANGE RED ORANGE BLUE INDIGO BLUE INDIGO CYAN WHITE CYAN WHITE GRAY BROWN GRAY BROWN B.
Var1 Var2 Var3 Var4 ------ ------ ------ ------ RED ORANGE BLUE INDIGO CYAN WHITE GRAY BROWN C.
Var1 Var2 Var3 Var4 ------ ------ ------ ------ RED ORANGE YELLOW GREEN BLUE INDIGO PURPLE VIOLET D.
Var1 Var2 Var3 Var4 ------ ------ ------ ------ RED ORANGE YELLOW GREEN BLUE INDIGO PURPLE VIOLET CYAN WHITE FUCSIA BLACK GRAY BROWN PINK MAGENTA

*The SAS certification sample problem and answer above are sourced from the official SAS sample questions page. All answer logs, data sets, output, and commentary are provided by this blog.

Correct Answer

Incorrect Answer

Click to see Answer Explanation below

thanks for your support

8 Comments

    Karan Verma May 28, 2015

    The trailing @ should be explained here, because of the trailing @ the results are coming the way, they are.

    Reply
        Utkarsh Oct 05, 2016

        Hi Hee jung, Above link does not exist any more, can you please help with a new Link if available.

        Reply
    aakash Dec 02, 2016

    this is the line hold specifier, the last @ does not allow the pointer to jump to the next line when the record has been read, so despite having a separate input statement, the records are written from the same line

    Reply
    Matthew Nov 24, 2017

    Since we used the trailing option in the input statement that holds the current record for the next input statement that conveys the SAS to read and returns the same position as it is mentioned in the input statement…

    Reply
    Cris Jan 07, 2018

    Umm does excluding the second input statement shows the same output?

    Reply
    Will Jan 08, 2018

    Why does the trailing @ on the second input statement not keep the pointer on the first data line? In other words, why is the output not just

    Red Orange Red Orange
    Red Orange Red Orange
    Red Orange Red Orange
    Red Orange Red Orange

    Reply
    Richie May 17, 2018

    That’s the result you would get if the second input line ended with “@@”, (double trailing at-symbol), which stops SAS from going to the next raw data line for each observation. The single symbol only holds the line for the next input statement in the same iteration of the data step.

    Reply

Leave a Comment

Please keep in mind that comments are moderated and rel="nofollow" is in use. So, please do not use a spammy keyword or a domain as your name, or it will be deleted. Let us have a personal and meaningful conversation instead.