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

Hello,

 

I have some quantity data on a daily basis. The date is formatted as DDMMYYN10.:

 

Date              Quantity

01JAN2020   10

01JAN2020   20

02JAN2020   15

02JAN2020   25

02JAN2020   10

03JAN2020     5

03JAN2020   15

03JAN2020   20

 

Now I'd like to create a table with the total quantity per day (without proc time series). The resulting table should look like this:

 

Date              Total Quantity

01JAN2020   30

02JAN2020   50

03JAN2020   40

 

How do I get that? I have tried numerous approaches (including calculating totals for each by group) but couldn't produce the above table. Any help would be greatly appreciated.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

HI @MarkusB   Master statsman @PaigeMiller would recommend PROC Summary

 

data have;
input Date :date9. Quantity;
format Date date9.;
datalines;
01JAN2020   10
01JAN2020   20
02JAN2020   15
02JAN2020   25
02JAN2020   10
03JAN2020   5
03JAN2020   15
03JAN2020   20
;

proc summary data=have nway;
class date;
var quantity;
output out=want(drop=_:) sum=total_quantity;
run;

View solution in original post

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

One way

 

data have;
input Date :date9. Quantity;
format Date date9.;
datalines;
01JAN2020   10
01JAN2020   20
02JAN2020   15
02JAN2020   25
02JAN2020   10
03JAN2020   5
03JAN2020   15
03JAN2020   20
;

proc sql;
    create table want as 
    select Date, Sum(Quantity) as TotalQuantity
    from have
    group by Date;
quit;
novinosrin
Tourmaline | Level 20

HI @MarkusB   Master statsman @PaigeMiller would recommend PROC Summary

 

data have;
input Date :date9. Quantity;
format Date date9.;
datalines;
01JAN2020   10
01JAN2020   20
02JAN2020   15
02JAN2020   25
02JAN2020   10
03JAN2020   5
03JAN2020   15
03JAN2020   20
;

proc summary data=have nway;
class date;
var quantity;
output out=want(drop=_:) sum=total_quantity;
run;
MarkusB
Calcite | Level 5
This works! Thanks a lot.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1359 views
  • 1 like
  • 3 in conversation