- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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 |
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It looks like you are starting with text that has not yet been read into a SAS data set. In that case, the more difficult step is preparing the data. For example, the dates need to become true SAS dates (not characters). And size needs to be converted to a number. Does that sound about right?
At any rate, once you confirm what data we are starting with, reading it in properly is the hard part. There are dozens of people here who can show you how to summarize it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Note: Also, it;s not mandatory to write output like this, I would be okay with as follows as well.
System Size
CXV 634.1 Gb
LZ0 3787.6 GB
QZ0 58.72 GB
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@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?