Writing the above code, I expected the result to be grouped by my first variable name i.e bankid. But it's grouping on Marital status which is 2nd variable. Plz explain why its not getting grouped by bankid though it's written as 1st variable in group by!
Your ORDER BY statement groups the data by descending COUNT, that's what is happening. That's the order of the output data. If you want some other order, you need a different ORDER BY statement. The GROUP BY statement does not determine the order of the output data.
Maybe you want a different ORDER BY statement?
The code and the result generated in correct, it gives exact ans while solving MCQ's but I didn't understand the logic that even after writing bankid first in the GROUP BY statement, the table is getting grouped by marital status first and then within the marital status the bankid is getting grouped.
I was assuming the marital status to be grouped within the bankid.
There is my confusion.
Your ORDER BY statement groups the data by descending COUNT, that's what is happening. That's the order of the output data. If you want some other order, you need a different ORDER BY statement. The GROUP BY statement does not determine the order of the output data.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.