Dear Members,
Please help with some calculation here.
Input Data: Here we have different systems (not only three, but it is also more than that), per system code we have some data in terms of GB with different dates. I have to calculate total "Size" for each "system" per month (assume here data is for Dec only).
Date | System | Size |
31/12/2022 | CXV | 158,9 Gb |
31/12/2022 | LZ0 | 947 Gb |
31/12/2022 | QZ0 | 14,68 Gb |
30/12/2022 | CXV | 158,7 Gb |
30/12/2022 | LZ0 | 946,9 Gb |
30/12/2022 | QZ0 | 14,68 Gb |
29/12/2022 | CXV | 158,4 Gb |
29/12/2022 | LZ0 | 946,9 Gb |
29/12/2022 | QZ0 | 14,68 Gb |
28/12/2022 | CXV | 158,1 Gb |
28/12/2022 | LZ0 | 946,8 Gb |
28/12/2022 | QZ0 | 14,68 Gb |
Output:
Date | System | Size |
Dec | CXV | 634.1 Gb |
Dec | LZ0 | 3787.6 GB |
Dec | QZ0 | 58.72 GB |
Assuming SIZE is a numeric variable (and not the text strings you have been displaying) just use PROC SUMMARY (also known as PROC MEANS). If the data is already sorted use BY statement, Otherwise you can use a CLASS statement and PROC SUMMARY will group the unsorted data for you.
proc summary data=have nway ;
class date system ;
var size ;
format date yymmd7.;
output out=want sum= ;
run;
Assuming that your dates are SAS date values, this will do it:
proc means data=have nway;
format date yymmd7.;
class date system;
var size;
output out=want sum()=;
run;
For working, tested code, always supply example data in a data step with datalines.
Is the sum over certain points a reasonable measure for "size"?
And if your time series does expand over more than a month ... how would you like to have the resulting sum split up then? Per Month? ... and if the year changes in between?
Assuming SIZE is a numeric variable (and not the text strings you have been displaying) just use PROC SUMMARY (also known as PROC MEANS). If the data is already sorted use BY statement, Otherwise you can use a CLASS statement and PROC SUMMARY will group the unsorted data for you.
proc summary data=have nway ;
class date system ;
var size ;
format date yymmd7.;
output out=want sum= ;
run;
@Tom wrote:
... just use PROC SUMMARY (also known as PROC MEANS). If the data is already sorted use BY statement, Otherwise you can use a CLASS statement and PROC SUMMARY will group the unsorted data for you.
Jupp ... as in Kurt's posting, i guess the two of you had the same thought.
@kumarsandip975 : That should be it, should it not?
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.
Ready to level-up your skills? Choose your own adventure.