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
D
ReplyDeletePlease note if you will use sum function result will be 100.
ReplyDeleteYou don't know what the Hell you're talking about, Amitabh
DeleteB
ReplyDeleteLa respuesta correcta es D.
ReplyDeleteYa que se esta usando la operacion suma, para que devuelva 100 se debe usar la funcion sum
TotalPassengers = Sum(OrigPassengers , TransPassengers);
Prueben el codigo.
i did'nt understand the language, but i understand what you are explaining :)
DeleteD
ReplyDeleteRan both the SUM function (Q59) and this one in SAS and see the output.
ReplyDeleteHowever, 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?
Sas will not generate the missing value when.
DeleteThen 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
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.
ReplyDeletethanks
Deletethat helped
yes ..makes sense..
DeleteAnd: D for Sure
ReplyDeletein 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...
ReplyDelete>> joydeep786@gmail.com
Answer is D for sure
ReplyDeleteThere is no addition for missing value for addition only.
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.
ReplyDeleteOnly 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.
MISSING! Giveaway is the + used as an operator while defining a new variable. Addition with missing variable , except the SUM Statement, is MISSING!
ReplyDeleteThis comment has been removed by the author.
DeleteB
ReplyDeleteCan you explain?
DeleteAns is D
ReplyDeleteexplanation--> 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.
A is ans as sum function ignore msg values : origpas as per prgm is missing and transpass is 100 so sum is 100
ReplyDeleteyou're right. I compiled it and got ans "A".
Deletesorry, I misunderstood the problem. ans is d for this coding. (the other one is a)
DeleteThis comment has been removed by the author.
DeleteD
ReplyDeleteThis comment has been removed by the author.
ReplyDeletewhat would have been the answer if we would have used retain total passengers 0;
ReplyDeletetotalpassengers+origpassengers+transpassengers;
if we use retain statement than the ans would be 100. Because the retain statement will not ignore the missing value.
DeleteThanks!!
This comment has been removed by the author.
ReplyDeleteAbsolutely D.
ReplyDeleteOutput will be:
OrigPassenger .
TransPassenger 100
NonPaying 10
TotalPassenger .
WHY
ReplyDeleteWHY
ReplyDeletehowever i run the program the output dataset shows that totalpassengers = 100
ReplyDeleteplease someone explain
ReplyDeleteThe 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.
ReplyDelete+ is a primitive operator while sum is designed to act over larger sets of data that may be missing some values.
Try this:
ReplyDeleteDATA sum;
function = SUM(1, .);
statement = 1+.;
RUN;
PROC PRINT DATA=sum;
RUN;
sum function ignore msg values
ReplyDeleteSUM=100+.=100
IN THIS CASE TOTAL =
IS MISSING
I ran the code, the answer should be D.
ReplyDelete9 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