View Full Version : SAS programming question


lulumohca777
03-03-2009, 10:37 AM
Hi,

I am trying to do this in SAS:

What data looks like

data test ;
Input Week $ JAN05 FEB05 MAR05 APR05 ;
Datalines;
product1 12 0 0 2
product2 0 0 0 4
product3 0 7 0 5
product4 0 10 9 8
product5 0 50 20 0
Run;

Results:

data result ;
Input Week $ fristm secondm thirdm fourthm ;
Datalines;
product1 12 0 0 2
product2 4 0 0 0
product3 7 0 5 0
product4 10 9 8 0
product5 50 20 0 0
Run;

So I have this dataset that has different products and they each have different release month of when they go on the market. because my original dataset starts at JAN05 while some products release later (product5 releases in FEB05)
I want to make the data set so instead of the columns going JAN05 FEB05...
I want it to show 1st month of sales, 2nd month of sales for each product.

And also since the products have a life of sales ranging from 1 month to 3 years how do I make a variable that shows the sum of the first 24 month of sales (only if the product has had 24 month of sales)?

I hope this makes sense.

Thanks!

vinux
03-03-2009, 12:49 PM
Use array and do loop.

array month{4} JAN05 FEB05 MAR05 APR05;
array mos{4} fristm secondm thirdm fourthm;
/* This you can extend as you like */

do i=1 to 4;
...
end;