Desktop productivity for business analysts and programmers

How to summarize monthly and yearly in SAS EG?

Posts: 21

How to summarize monthly and yearly in SAS EG?



My problem is:

I have to summarize datas by monthly, and after by yearly, in separated tables. I also have to do it in EG (maybe querry), but I don't know how to solve this.

I have datas as month (januar-December) and year (2002-2004), income, and the name of product. I have to sum it monthly, and yearly. (of course in monthly I mean in the same year. so Jan 2002 can't be sum with Jan 2003). 

I attach a .txt file, with my expectation and the base data table.


I hope you can help me somehow. Smiley Happy


Thank you.


ps. I am not allowed to code it. I have to use the GUI. Smiley Happy

Posts: 1,332

Re: How to summarize monthly and yearly in SAS EG?

So, step 1 is to convert the monthname to a number (January =1), etc. First use the "Create Format" task to create an infromat that will match the character values to the numeric. Then, in a query, use an advanced expression and the INPUT function to convert your character names to numbers.


Now, also in a query with an advanced expression, use the MDY function to convert your individual month, day, and year numeric values to a SAS date value.


From here on, run your tables using whichever tabulation procedure you like. For the annual table, apply the YEAR format to your date variable while building the table. For the monthly summary, use the YYMM format.

Super User
Posts: 23,932

Re: How to summarize monthly and yearly in SAS EG?

1. In Query Builder create two new variables, one is year and one is month. Both are functions that can be created via compute column.


2. Use the Summarize task to build your summary table. For the annual use your year variable as your grouping variable, for monthly use the year and month as your group variables. 



Posts: 21

Re: How to summarize monthly and yearly in SAS EG?

Thank you for your answers, both seems okay, but I found a solution as wells. It is a 'report maker' (?), if I am correct, because I don't have EN version. It summarize it by month, and by year if I select the year. Smiley Happy

Anyways, thank you again! Smiley Happy

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation