BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
crawfe
Quartz | Level 8

Hi. I am learning to work with teradata code in DI Studio to speed up processing of large tables

(Advice from my admin).

This might be more of a strategy question. How to SUM by a Group A only.

The Group By requires all the non-aggregated columns to be listed, which seems awkward.

Please correct me if I understand it wrong.

 

HAVE: Columns A B C D(variable)

WANT:   The SUM of D(variable) Grouped By A only.

If 3 different A values:

3 groups: Group A1 - sum(Dvar), Group A2 - sum(Dvar), Group A3 - sum(Dvar)

HOW (in TD): SUM(D(variable); Group By A B C (must include all columns?!)

GET?:

3 x 3 combinations of grouping: A1B1C1 sum(Dvar), A1B1C2 sum(Dvar), A1B1C3 sum(Dvar)etc.

 

I could do brute force and split off a table of A D(variable), perform my sum/group, then rejoin.

Is there a more efficient way?

Any advice would be appreciated! Eventually this will be reported in Viya.

1 ACCEPTED SOLUTION

Accepted Solutions
crawfe
Quartz | Level 8

Yes, I want a column of var by GroupA only, Group AB only, Group ABC only. Teradata seems a little harder to do that (in DI Studio). As you say, the answer is probably in the Group By Rollup variations. Thanks.    

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

It is is not at all clear what you are asking for.  Are you asking to generate output like you would get with PROC SUMMARY where you have some rows that represents values grouped say just variable A and others where the data is grouped by A and B. Or A, B and C.

 

If so then you probably are looking for the CUBE GROUPING SETS feature of Teradata.

https://docs.teradata.com/reader/b8dd8xEYJnxfsq4uFRrHQQ/5uCbXZ6cjrhyOZfoCwkiDg

 

crawfe
Quartz | Level 8

Yes, I want a column of var by GroupA only, Group AB only, Group ABC only. Teradata seems a little harder to do that (in DI Studio). As you say, the answer is probably in the Group By Rollup variations. Thanks.    

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 680 views
  • 0 likes
  • 2 in conversation