BookmarkSubscribeRSS Feed
pjpnk
Fluorite | Level 6

 

Hello - I am stuck here can someone please explain what would be the answer?

 

Based on this program and the observation shown in the PDV, what variable’s value is assigned to Amount?

 

PDV

Emp

ID

Pay

Class

 Hrs

Amount

Job

Rate

Msg

1201

Contract

30

.

.

 

 
data payroll;
   set salaries;
   if PayClass='Monthly' then Amount=Salary;
   else if PayClass='Hourly' then do;
      Amount=HrlyWage*Hrs;
      if Hrs>40 then Msg='CHECK TIMECARD'; 
   end;     
   else Amount=JobRate;
run;
 
a.)not specified
b.)HrlyWage*Hrs
c.)JobRate
d.)Salary
 
Any help would be appreciated. 
Pankajwa
7 REPLIES 7
PeterClemmensen
Tourmaline | Level 20

Who asked you this question?

 

What do you think is the answer and why?

pjpnk
Fluorite | Level 6

sorry..! while practice I got this question and the answer given is the option D (Salary) as correct. but I am confused.

Pankajwa
ballardw
Super User

@pjpnk wrote:

sorry..! while practice I got this question and the answer given is the option D (Salary) as correct. but I am confused.


 

I would go back to the source and verify that the PDV you show is accurate. Since you don't show a variable SALARY in the PDV then something is odd. If there actually is not variable SALARY in the dataset SALARIES then this line would create the variable SALARY with a missing value:

if PayClass='Monthly' then Amount=Salary;

and a note about SALARY was uninitialized.

 

At which point SALARY = JOBRATE (both missing).

But since the PDV is ALSO missing HrlyWage I suspect that your PDV description is incomplete.

One common test of doubtful questions is to create the "data" and run the code:

data salaries;
   empid='1201';
   payclass='Contract';
   hrs = 30;
   amount=.;
   jobrate=.;
   msg = '   ';
run;
   
data payroll;
   set salaries;
   if PayClass='Monthly' then Amount=Salary;
   else if PayClass='Hourly' then do;
      Amount=HrlyWage*Hrs;
      if Hrs>40 then Msg='CHECK TIMECARD'; 
   end;     
   else Amount=JobRate;
run;
Astounding
PROC Star

That's the source of your confusion.  Your link does not select D as the correct answer, but selects C instead.  C is correct.  The first two IF/THEN conditions are false, so the last statement in the DATA step executes.

Astounding
PROC Star

Actually, the PDV doesn't match the program.  If it did, it would also contain a spot for Salary and HrlyWage.

pjpnk
Fluorite | Level 6

here is the original source of the question - 

http://support.sas.com/training/us/crs/quiz/prg1/chapter9x.htm

Pankajwa

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 2062 views
  • 1 like
  • 4 in conversation