Hi.
I have just finished lesson 10 of sas programming1 and have a doubt with question 8 of its final quiz for this lesson. My answer is b, where as the system marks it wrong and says it is c. can someone explain how?
This is the link to the quiz, for your reference:
https://support.sas.com/edu/OLTRN/ECPRG193/m421/m421_5_b_quiz.htm
Thanks in advance
Nidhi
I don't have to 'think', I tested it.
The key idea is here, not what you think will happen, but what SAS does. Your understanding/expectations are good to have and consider but all that matters is what actually happens. You may want different behaviour but it's good to know when things won't behave as you expect. I think the key from the documentation is in the details section when it discusses BY group processing.
Specify the IN= data set option in parentheses after a SAS data set name in the SET, MERGE, MODIFY, and UPDATE statements only. Values of IN= variables are available to program statements during the DATA step. These variables are not included in the SAS data set that is being created, unless they are assigned to a new variable.When you use IN= with BY-group processing, and when a data set contributes an observation for the current BY group, the IN= value is 1. The value remains as long as that BY group is still being processed and the value is not reset by programming logic.
The answer is A, and it provides a brief explanation:
"The SAS data sets first and second have a one-to-one matching relationship. Each observation in first matches one and only one observation in second."
Hi.
I have just finished lesson 10 of sas programming1 and have a doubt with question 10 of its final quiz for this lesson. My answer is b, where as the system marks it wrong and says it is c.
You said Question 10.
@nrmahindru wrote:
Are you sure you are checking the right question? I am talking about #8 from lesson 10 of sas programming 1 essentials. I checked again it says correct answer is C whereas I am getting B. It is about merging data sets.
Now it's Question 8.
So which one are you looking at?
Because the key variable on the BY statement is in both data sets then it's marked as 1 for each.
Remember you can actually run the code and check the answer.
Add the following to the data step if you need to see the actual values.
vara = A;
varC = C;
Hi Reeza,
Thanks for getting back again.
I do get your point but when we are talking of the second iteration, does it not take values only from amounts?
let me explain what i am thinking:
1st iteration...both same names so both contribute to the output dataset. hence C=1 and A=1
2nd iteration...not same names but the name on amounts matches the one in PDV already... so only amounts contributes to the output dataset. hence C=0 and A=1.
What am I missing here and where am i going wrong.
Really need to clear this.
When all else fails, read the documentation. What does it say regarding IN data set option?
i think i need to read it carefully again. As per my understanding it says what i have stated above. Maybe i need to revisit.
what do you think is the correct answer?
I don't have to 'think', I tested it.
The key idea is here, not what you think will happen, but what SAS does. Your understanding/expectations are good to have and consider but all that matters is what actually happens. You may want different behaviour but it's good to know when things won't behave as you expect. I think the key from the documentation is in the details section when it discusses BY group processing.
Specify the IN= data set option in parentheses after a SAS data set name in the SET, MERGE, MODIFY, and UPDATE statements only. Values of IN= variables are available to program statements during the DATA step. These variables are not included in the SAS data set that is being created, unless they are assigned to a new variable.When you use IN= with BY-group processing, and when a data set contributes an observation for the current BY group, the IN= value is 1. The value remains as long as that BY group is still being processed and the value is not reset by programming logic.
Ok. So the fact that the value of the by group is not being reset is making all the difference here. I do see what is happening, which was definitely different from what i was expecting, but was unable to understand the logic behind it.
thanks for your time.
I think if you run it you'll see why. Think of it this way, although that first table has a single record it's matched against each in the other table and any corresponding data, in this case the EmpID is also brought across. If it wasn't, the EMPID would be missing which isn't you'd expect either. But consider a situation where you have more than just EMPID.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.