Someone can explain the code below to me? I am confused by Group by 1, 2, 3, 4, because there is no variable and value called 1, 2, 3, 4.
proc sql; create table SampleData as select
uniqID, Category, Grade, Value,
count(uniqID) as CNT,
avg(PRICE) as APR,
avg(Value) as ALE
from DataIn where date ge &intdt. group by 1,2,3,4;
quit;
Example: Group By single column: Group By single column means, to place all the rows with same value of only that particular column in one group.
The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of customers in each country". The GROUP BY statement is often used with aggregate functions ( COUNT() , MAX() , MIN() , SUM() , AVG() ) to group the result-set by one or more columns.
it means order by the very first column from the select list.
The GROUP BY clause is used to get the summary data based on one or more groups. The groups can be formed on one or more columns. For example, the GROUP BY query will be used to count the number of employees in each department, or to get the department wise total salaries.
It's a relative reference to the 1st, 2nd, 3rd, and 4th variables in your select statement. Ie. uniqID, Category, Grade, Value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With