BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
POOJA_J
Obsidian | Level 7

POOJA_J_0-1697457229593.png

POOJA_J_3-1697457454707.png

 

POOJA_J_2-1697457330267.png

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

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.

--
Paige Miller

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Maybe you want a different ORDER BY statement?

--
Paige Miller
POOJA_J
Obsidian | Level 7

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. 

PaigeMiller
Diamond | Level 26

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.

--
Paige Miller
POOJA_J
Obsidian | Level 7
Great its solved now. Thanks for explaining.

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!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 385 views
  • 1 like
  • 2 in conversation