ElearnSAS.com

ElearnSAS.com
SAS Learning Platform

Base SAS 60

The following SAS program is submitted:data work.passengers;
data work.passengers;
if OrigPassengers = . then
OrigPassengers = 100;
TransPassengers = 100;
OrigPassengers = .;
NonPaying = 10;
TotalPassengers = OrigPassengers + TransPassengers;
run;
Which one of the following is the value of the TOTALPASSENGERS variable in the output data set?
A. 100
B. 110
C. 200
D. . (missing numeric value)
Click Comment link to get answer

39 comments:

  1. Please note if you will use sum function result will be 100.

    ReplyDelete
    Replies
    1. You don't know what the Hell you're talking about, Amitabh

      Delete
  2. La respuesta correcta es D.
    Ya que se esta usando la operacion suma, para que devuelva 100 se debe usar la funcion sum
    TotalPassengers = Sum(OrigPassengers , TransPassengers);
    Prueben el codigo.

    ReplyDelete
    Replies
    1. Anonymous3:02 AM

      i did'nt understand the language, but i understand what you are explaining :)

      Delete
  3. Anonymous3:55 PM

    Ran both the SUM function (Q59) and this one in SAS and see the output.

    However, could someone explain why the SUM may add a missing value and get a numeric value whereas the addition in Q60 may not "accept" the missing value?

    ReplyDelete
    Replies
    1. Sas will not generate the missing value when.
      Then variable create with sum statement
      variable create with Retain statement
      variable create with options in infile Or file name statement
      variable create with _temporary_ array.

      For more information search When Missing Values Are Generated by SAS

      Thanks

      Delete
  4. Anonymous4:29 PM

    all summary function ignore missing value when computing values whereas operators like + - / * etc do not ignore missing. Thus SUM function will give non missing output as long as their is atleast one variable with non missing value. Whereas the operator will always give missing as long as atleast one variable in operation is missing. Hope this makes sense.

    ReplyDelete
  5. Anonymous5:25 PM

    in question no 59 sum() function used, sum() ignores missing value----but in question no 60 a assignment atatemnt is used, for this case , since the value of origpaassnger values becomes . (missing), so the value of total passenge become missing......hope u hv understood...

    >> joydeep786@gmail.com

    ReplyDelete
  6. Answer is D for sure
    There is no addition for missing value for addition only.

    ReplyDelete
  7. Anonymous10:43 PM

    If you follow the logical path, OrigPassnger . ( missing is added with Transpassanger 100 which total should be 100 but if you run on sas program it gives missing.
    Only USA said B and how he/she got that answer ?

    Anyone can give us logic why it is generating the missing value even the Transpassangers value 100 is turning to missing?

    Again, in test we are not allowed to run sas and get answer. Let's feed the brain with logic.

    ReplyDelete
  8. Remya1:10 PM

    MISSING! Giveaway is the + used as an operator while defining a new variable. Addition with missing variable , except the SUM Statement, is MISSING!

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
  9. Ans is D
    explanation--> In Sum Statement missing is considered as the least value ie 0.. how ever when we use the operators like + - ...etc, missing value is not ignored and considered as missing even though the other variable has a value in the statement.

    ReplyDelete
  10. A is ans as sum function ignore msg values : origpas as per prgm is missing and transpass is 100 so sum is 100

    ReplyDelete
    Replies
    1. Anonymous9:05 PM

      you're right. I compiled it and got ans "A".

      Delete
    2. Anonymous12:24 AM

      sorry, I misunderstood the problem. ans is d for this coding. (the other one is a)

      Delete
    3. This comment has been removed by the author.

      Delete
  11. This comment has been removed by the author.

    ReplyDelete
  12. what would have been the answer if we would have used retain total passengers 0;
    totalpassengers+origpassengers+transpassengers;

    ReplyDelete
    Replies
    1. if we use retain statement than the ans would be 100. Because the retain statement will not ignore the missing value.

      Thanks!!

      Delete
  13. This comment has been removed by the author.

    ReplyDelete
  14. Gerrit12:29 PM

    Absolutely D.

    Output will be:
    OrigPassenger .
    TransPassenger 100
    NonPaying 10
    TotalPassenger .

    ReplyDelete
  15. Anonymous11:54 AM

    however i run the program the output dataset shows that totalpassengers = 100

    ReplyDelete
  16. please someone explain

    ReplyDelete
  17. Anonymous9:09 PM

    The explanation is that the function sum and the + operator act differently. Sum ignores missing values while using + with a missing value gives a missing value.

    + is a primitive operator while sum is designed to act over larger sets of data that may be missing some values.

    ReplyDelete
  18. Anonymous4:26 PM

    Try this:

    DATA sum;
    function = SUM(1, .);
    statement = 1+.;
    RUN;
    PROC PRINT DATA=sum;
    RUN;

    ReplyDelete
  19. Anonymous9:12 PM

    sum function ignore msg values
    SUM=100+.=100
    IN THIS CASE TOTAL =
    IS MISSING

    ReplyDelete
  20. Anonymous7:11 PM

    I ran the code, the answer should be D.
    9 data test;
    10 if OrigPassengers = . then
    11 OrigPassengers = 100;
    12 TransPassengers = 100;
    13 OrigPassengers = .;
    14 NonPaying = 10;
    15 TotalPassengers = OrigPassengers + TransPassengers;
    16 run;

    NOTE: Missing values were generated as a result of performing an operation on missing values.
    Each place is given by: (Number of times) at (Line):(Column).
    1 at 15:34
    NOTE: The data set WORK.TEST has 1 observations and 4 variables.
    NOTE: DATA statement used (Total process time):
    real time 0.41 seconds
    cpu time 0.07 seconds

    ReplyDelete