BookmarkSubscribeRSS Feed
CesarOmarHR
Calcite | Level 5

Hi there

I want to generate a summarized column with the total value of the elements in the column repeating each time.

Number of cars          Total Number of cars

1                                   5

.                                   .

.                                   .

.                                   .

.                                   .

.                                   .

1                                   5

1                                   5

1                                   5

1                                   5

I'm using SAS EG, but can't find the correct option among the sum, count, N, sum distinct, count distinc commands.

Thanks

2 REPLIES 2
TomKari
Onyx | Level 15

Hi, Cesar

Could you perhaps expand on this a little? Provide some sample data, and the results that you want?

Thanks,

  Tom

audioa84
Calcite | Level 5

With the limited info you have given us, I would suggest the following. From your original data set, bring in all the columns you wish to have. If we are going of your example, bring in Number of cars twice Then select SUM under Summary for the column you wish to total. The last step is to deselect "Automatically select grouping". This should fix the problem you where having. If it doesn't, supply more details and I'm sure someone can help.

Thanks,

Mark

BTW your results should resemble the table found below:

Num_of_Cars  Car_Model    Model_Year      Sum_of_Num_of_Cars

     1                  A                  2000                        15

     2                  B                  2001                        15         

     3                  C                  2002                        15

     4                  D                  2003                        15

     5                  E                  2004                        15

Also, the SQL should be similar to the code below (the SQL code for a Query Builder can be found by clicking Preview).

PROC SQL;

CREATE TABLE LIBRARY.QUERY_FOR_DATASETS AS

SELECT t1.Num_of_Cars,

t1.Car_Model,

t1.Model_Year,

....

(SUM(t1.Num_of_Cars)) AS SUM_of_Num_of_Cars

FROM LIBRARY.DATASET t1;

QUIT;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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