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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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