Hello,
I have data in excel trying to make a report in SAS with similar format output as seen below. This is just sample, but I want the exact format with row being on left side, where I can calculate column differences and percentage changes. Really appreciate your help. Thank!
You are sort of missing some details. Do expect the report to do the "total sales" from the individual areas like Product A Sales etc?
Do the "Product A/B/C " or whatever have more than one observation each in your source data?
How do we know which sales value is associated with which "month".
You should provide an example of what your current data looks like in the form of a data step.
FWIW, that is not a complex report. It might be done in Proc Report or Proc Means/ a data step and Proc Print.
The details actually do depend on the content of your data set. Do you have a SAS data set yet?
Hi,
@ballardw is correct. How you approach this will depend a lot on the structure of your data and what procedure you use. For example SASHELP.PRDSAL2 has multiple years of product/sales data, each year is on a separate row. So with PROC REPORT, I would need to use the YEAR variable as an ACROSS item (I only used 2 years in this example to simplify the program and make it closer to your Month1 and Month2 example.
With an ACROSS item in PROC REPORT, you'd need to understand that PROC REPORT would generate absolute column numbers for the variable columns under the ACROSS item. That's why the program refers to _C2_ (values for 1996 sum of ACTUAL) and _C3_ (values for 1997 sum of ACTUAL). Then I can use the DIFF and the PCTCHG columns as computed items. Using RBREAK BEFORE allows the Total row to appear at the top of the report like this:
Of course a different data structure might require different procedures and/or different logic.
Cynthia
Will just add to the above comments that if you are not familiar with all of the calculation and variable creation features of Proc Report, you can just create your final report variables of interest using a Data Step a/or Proc Means (with output). Then use Proc Report and that final SAS data file to create the table you want.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.