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;
Who asked you this question?
What do you think is the answer and why?
sorry..! while practice I got this question and the answer given is the option D (Salary) as correct. but I am confused.
@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;
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.
Actually, the PDV doesn't match the program. If it did, it would also contain a spot for Salary and HrlyWage.
here is the original source of the question -
http://support.sas.com/training/us/crs/quiz/prg1/chapter9x.htm
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.
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.