Help using Base SAS procedures

Making use of Tabulate in SAS for complex data

Reply
N/A
Posts: 0

Making use of Tabulate in SAS for complex data

Hello All ,

Iam stuck in how do i make use of the TABULATE as I need to generate the breakdown of the revenues for both week 1 & 2 and also for both laptop models sold ( AT3600 and AP3965 ) .Since i have been given that the price of the laptop AT3600 and AP3965 are $ 1,99.99 and $ 299.99 respectively for the week 1 ( 01/11/2009 - 01/11/2009 ) and , whereas , the price of the model AT3600 is still $ 1,99.99 but for the model AT3600 it rises to $ 4,99.99 for the model AP3965 in the week 2.

secondly , the problem is complicated in that the owner of the company follows the policy that Laptops purchased before 3pm will be shipped that day but those purchased after 3pm will be shipped the following day and he wants to find the proprtion of the tarnsactions that qualify for the same day delivery.A sample of the datatable is below :

DATA salesforecast;
INPUT TransactionID $ DateofSale $ TimeofSale $ LaptopModel $ UnitsSold ;
DATALINES;
RX000141 01/11/2009 08:49:26 AT3600 2
RX000135 01/11/2009 09:50:39 AP3965 2
RX000149 02/11/2009 11:54:23 AP3965 2
RX000143 02/11/2009 10:27:08 AP3965 2
RX000152 03/11/2009 11:27:53 AP3965 5
RX000156 03/11/2009 09:35:58 AP3965 1
RX000170 04/11/2009 05:55:50 AT3600 5
RX000166 04/11/2009 10:31:42 AP3965 2
RX000179 05/11/2009 12:32:28 AP3965 5
RX000173 05/11/2009 10:08:52 AP3965 1
RX000189 06/11/2009 09:07:45 AT3600 5
RX000183 06/11/2009 15:19:52 AP3965 1
RX000207 07/11/2009 04:02:08 AT3600 2
RX000197 07/11/2009 09:24:13 AP3965 1
RX000215 08/11/2009 14:09:49 AP3965 2
RX000208 08/11/2009 12:46:52 AP3965 2
RX000230 09/11/2009 19:28:32 AP3965 2
RX000231 09/11/2009 18:34:52 AP3965 1
RX000247 10/11/2009 14:14:41 AP3965 2
RX000245 10/11/2009 10:06:17 AP3965 2
RX000258 11/11/2009 06:02:42 AP3965 2
RX000260 11/11/2009 11:33:21 AP3965 1
RX000264 12/11/2009 18:38:03 AP3965 1
RX000265 12/11/2009 19:25:19 AP3965 1
RX000281 13/11/2009 09:14:42 AP3965 2
RX000288 13/11/2009 16:37:03 AT3600 2
RX000295 14/11/2009 11:12:00 AP3965 2
RX000293 14/11/2009 04:23:26 AP3965 1
;
PROC PRINT data = salesforecast;
RUN;

.In particular , I could not find a code that will find the breakdown of revenue from the two laptops for the two week period .

Kind Regards ,

mark
Super Contributor
Super Contributor
Posts: 3,174

Re: Making use of Tabulate in SAS for complex data

Posted in reply to deleted_user
You made a similar post here:

http://support.sas.com/forums/thread.jspa?threadID=8692&tstart=0

With this latest post, what SAS programming logic *HAVE* you attempted that did not work, possibly? You will get the most benefit by asking for guidance with some self-initiative rather than asking from someone else to do the programming for you.

So, here you go:

1) consider the INTNX function (or YEAR and WEEK functions) to derive a week-of variable, and if you go with INTNX to assign a SAS WEEK_START_DATE variable, apply a SAS FORMAT for a suitable date value in your code somewhere.

2a) the time-constant for 3:00PM is "15:00:00"T -- so if you want to assign a SHIPS_TODAY variable, say a value of 1 or 0 (so you can do summary analysis), or....

2b) consider combining you "date" and "time" variables together using the DHMS function to create a SAS numeric DATETIME variable, allowing you to increment and decrement the date-portion and/or move forward/backward the time or date portion using the INTNX function, when needed -- I am only suggesting this because you make mention about shipping dates and transaction dates/times.


3) recommend you start with "basic" SAS procedures and so you may consider MEANS or SUMMARY (and PRINT), rather than TABULATE.

So, with this guidance, I encourage you strongly to go digest the SAS documentatoin in each of these areas, develop a "logic flow" diagram on paper/whatever, then begin pecking away at SAS programming elements needed to get the desired report output, or otherwise.

And, when you feel you have made progress and then have a specific challenge, come back to the forum, with a new post, properly titled, and share your SAS log output with a problem/challenge you might have. We don't need to see your raw data ever time - just a data-sample (suitable for the post) is all that's needed.

And, again, the SAS eLearn web site will be your friend for the coming days, weeks, months. Also there are SAS learning books you can purchase, readily available to help you learn the fundamentals about the SAS system and programming it out-the-wazoo!

Scott Barry
SBBWorks, Inc.
Respected Advisor
Posts: 4,173

Re: Making use of Tabulate in SAS for complex data

And you actually made also a post at http://groups.google.com/group/comp.soft-sys.sas/browse_thread/thread/73059e330a18e536 which I answered in a similar - also not so elaborate - way than Scott.
N/A
Posts: 0

Re: Making use of Tabulate in SAS for complex data

Thank you so much for that . I could now start to understand the code and manipulate with the data .


Thank you so much.

kind regards,
mark
Ask a Question
Discussion stats
  • 3 replies
  • 111 views
  • 0 likes
  • 3 in conversation