what is difference between datalines and cards statement

Viewed 5046

I am seeking job on SAS tool. interviewer asked me this question I said no difference, both are used to read internal data but he told there is a difference between cards and datalines statement .

kindly help me to crack this question.

1 Answers

There is no significant difference between the two. CARDS is defined as an alias of DATALINES, and by definition an alias should have identical behavior to the statement it is an alias of.

There is an insignificant difference, which is really simply an undefined behavior; it is explained on page 4 of Andrew Kuligowski's 2007 paper, and related to how cards and datalines have slightly different results when used in a file statement (which they are not intended to be used with). The behavior is slightly different now for datalines in modern SAS (9.4); it gives an error, but a different one from cards. However, it is simply undefined behavior; it would be an absurd thing for an interviewer to expect as an answer.

Your interviewer may have been referring to datalines versus datalines4, or cards versus cards4; those are different, because the latter requires four ; to end instead of one (to allow for the possibility of a semicolon in the data itself).

Related