BookmarkSubscribeRSS Feed
billfriend
Fluorite | Level 6

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. 

8 REPLIES 8
mkeintz
PROC Star

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.

--------------------------
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set

Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets

--------------------------
Reeza
Super User

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

billfriend
Fluorite | Level 6

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.

Reeza
Super User

Post some sample data and your expected output. Please post as a data step, see instructions here:

https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat...

 

You can also google a paper called ‘creating complex reports’ by Cynthia Zender that walks through how to create presentation ready tables. 

billfriend
Fluorite | Level 6

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);

Reeza
Super User

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.

billfriend
Fluorite | Level 6
I ran the macro, closed it. I don't have SAS University Edition so I am confused about Autoexe.
I tried to run:
>%data2datastep(mydatasetname,sashelp,,10)
This kept giving me an error, sashelp.mydatasetname does not exit.

Also, I'm not worried about creating complex tables, I'm just unsure what to fill those table shells with. Thank you!
Reeza
Super User

 

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.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 8 replies
  • 1293 views
  • 0 likes
  • 3 in conversation