BookmarkSubscribeRSS Feed
hchan10
Calcite | Level 5

can some one help me with the code for this problem ?

 

data trans;
input CustomerID transactiondate$ 10. amount category$;
cards;
9801234 10/01/1998 123.98 toys
9802234 12/10/1997 80.34 books
9802234 12/10/1997 100.00 apparel
9805556 08/01/1996 22.90 toys
9805556 09/10/1996 25.50 apparel
9805556 10/11/1996 18.90 books
9801134 11/11/1999 12.11 toys
;
run;


Total and average amount spent by category 

  1. Which category has the highest average purchase
  2. What is the average number of categories that customers purchase
  3. What is the average and total amount by customer
  4. What is the average number of days between purchases (as of today)
3 REPLIES 3
Norman21
Lapis Lazuli | Level 10

What code have you written?

Norman.
SAS 9.4 (TS1M6) X64_10PRO WIN 10.0.17763 Workstation

PaigeMiller
Diamond | Level 26

For numbers 1, 2 and 3, use PROC SUMMARY.

--
Paige Miller
Reeza
Super User

Here are some tutorial video's that will help you answer your question:

http://video.sas.com/detail/videos/sas-analytics-u/video/3306906230001/summary-statistics-using-sas-...

 

http://video.sas.com/detail/videos/sas-analytics-u/video/4573023399001/creating-a-new-column-in-sas?...

 


@hchan10 wrote:

can some one help me with the code for this problem ?

 

data trans;
input CustomerID transactiondate$ 10. amount category$;
cards;
9801234 10/01/1998 123.98 toys
9802234 12/10/1997 80.34 books
9802234 12/10/1997 100.00 apparel
9805556 08/01/1996 22.90 toys
9805556 09/10/1996 25.50 apparel
9805556 10/11/1996 18.90 books
9801134 11/11/1999 12.11 toys
;
run;


Total and average amount spent by category 

  1. Which category has the highest average purchase
  2. What is the average number of categories that customers purchase
  3. What is the average and total amount by customer
  4. What is the average number of days between purchases (as of today)

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 662 views
  • 0 likes
  • 4 in conversation