I have data with several variables including store_id, location, and product_cat. Store_Id ranges from 1-8, location ranges from 1-9 (representing outside, entrance etc.), and product_cat ranges from 1-8 (representing candy, cereal, etc). I need the mean number of "displays/counts" per store by location and product_cat. I'm unsure how to transform this data to get the correct information.
Please show how the data is arranged now, as in a SAS data step. Then are layout of what the desired results would look like.
Help us help you.
Try a summary procedure such as PROC MEANS/SUMMARY.
You can add multiple variables into the BY statement, and SAS will break down the analysis by the variables in the BY statement.
Basic tutorials/demo is here:
https://github.com/statgeek/SAS-Tutorials/blob/master/proc_means_basic.sas
This is great, thank you! Quick question-I am not reporting by store. My table shells look like this:
Locations | Mean (SD) | Range |
Outside |
|
|
Entrance |
|
|
EndCap A |
|
|
EndCap B |
|
|
Aisle |
|
|
Edge |
|
|
Checkout side |
|
|
Checkout edge |
|
|
Island |
|
|
Food Product Categories | Mean (SD) | Range |
Cereal |
|
|
Candy |
|
|
Chips |
|
|
Cookies |
|
|
Fruits and Vegetables |
|
|
Fruit Drink |
|
|
Soda |
|
|
Beverages |
|
|
I am confused as to what to report. I can't just take the "by STORE_ID;" out.
Post some sample data and your expected output. Please post as a data step, see instructions here:
You can also google a paper called ‘creating complex reports’ by Cynthia Zender that walks through how to create presentation ready tables.
I'm having a hard time getting this to work. I have SAS version 9.4. I downloaded the macro and have it opened in my SAS; I don't use macros that are this complicated very often, so it's a bit confusing. Do I edit the top line?
%macro data2datastep(mydatasetname?,lib,outlib,file,obs,fmt,lbl);
Don’t touch the macro code. Run it once and then close that program.
Run through the instructions exactly first and then try it on your data.
Top of the post:
%data2datastep(dsn, lib, file, obs);
dsn = input data set name, required
lib = library where input data set resides, optional
file = name of output file, optional
obs = number of obs to include in the data step, optional
Lib, the second parameter is the library where the data set is stored. I'm assuming your data set is not in the SASHELP library but most likely the WORK library. Just leave it empty and it should work.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.