BookmarkSubscribeRSS Feed
Q1983
Lapis Lazuli | Level 10

proc sql;

create table test as

select catg as catg1, sum(apps) as apps, gla,mdy

from test2

group by catg,apps,gla

;quit;

Output

catg           apps                gla          mdy

233             1                     100       01jun2014

233             3                     100      01jun2014

234             5                     50       01jul2014

235            5                     100     01aug2014

 

Aggregate totals not working how can I get this instead

catg           apps                gla          mdy

233             4                    200       01jun2014

234             5                     50       01jul2014

235            5                     100     01aug2014

So in this exmple the 233 should be totalling since the catg repeats

2 REPLIES 2
ballardw
Super User

You will have to show what the input data set looks like. Best is as a data step so there is no question about data type or other characterisitc.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

 

But since your data apparently has values of GLA = 100 then when you group by GLA you are not going to get any sum=200.

Reeza
Super User

You shouldn't have apps in the select or group statements if you want to summarize that variable. 

 

Remeber to define your grouping variables first and put them in your Select/Group statements and then do you summary statistics.

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!

How to Concatenate Values

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.

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
  • 989 views
  • 0 likes
  • 3 in conversation