BookmarkSubscribeRSS Feed
Mariloud
Obsidian | Level 7

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!

pic.png

3 REPLIES 3
ballardw
Super User

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?

Cynthia_sas
SAS Super FREQ

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:

Cynthia_sas_0-1708889018863.png

 

  Of course a different data structure might require different procedures and/or different logic.

Cynthia

 

rmacarthur
Pyrite | Level 9

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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 245 views
  • 0 likes
  • 4 in conversation