Date: Wed, 10 Nov 2010 18:43:15 -0500
Reply-To: Michael Bryce Herrington <mherrin@G.CLEMSON.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Michael Bryce Herrington <mherrin@G.CLEMSON.EDU>
Subject: Re: Variable creation help
In-Reply-To: <B282BE35B5A4494894D4ECFBA2BF7847180BB3CB56@XCH-NW-17V.nw.nos.boeing.com>
Content-Type: text/plain; charset=ISO-8859-1
I had a question asking to better explain the goal I would like. I do not
know how to use arrays well enough to implement it, but I do believe they
could be used effectively.
For the first variable I am looking for something that will indicate if a
product has outsold one of the other products in todays market.
Q: Has 'a' outsold 'c' 'g' or 'e'?
A: find all other markets 'a' has been in and compare it's rank for others
in both markets.
a outsold c in group 1 so 'outsold_competitor'=1
c outsold g in group 2 so 'outsold_competitor'=1
g has not outsold any of a, c, e so 'outsold_competitor'=0
e outsold g in group 4 so 'outsold_competitor'=1
I would like to create this for all groups using only previous markets. The
resulting data set would be what I have below. I have many more groups and
products so there would not be as many '1' but this is a general idea. I
have also added an "outsoldby_competitor" variable indicating if two
products have been in the same market before and the product in question has
been outsold by one of its competitors. And # of times outsold which
indicates how many times the product in question has outsold one of its
competitors. But again I think if you help me with the first variable I can
edit it such that I can define the other variables on my own. Thanks
*
data* sample;
input group id $ rank outsold_competitor beenoutsoldby_competitor
timesoutsold_competitor;
datalines;
0 a . 1 1 4
0 c . 1 1 2
0 g . 0 1 2
0 e . 1 1 3
1 a 1 1 1 3
1 b 2 1 1 1
1 c 3 1 1 1
1 d 4 1 0 5
1 e 5 1 1 2
2 c 1 1 1 1
2 f 2 0 1 0
2 g 3 1 0 1
3 d 1 1 0 1
3 a 2 1 0 1
3 c 3 0 1 0
3 f 4 0 0 0
3 b 5 0 0 0
4 e 1 1 0 1
4 g 2 0 0 0
4 h 3 0 0 0
4 i 4 0 1 0
4 a 5 0 0 0
4 c 6 0 0 0
5 d 1 0 0 0
5 b 2 0 0 0
5 e 3 0 0 0
5 i 4 0 0 0
;
*
run*;
Thanks.
--
Bryce Herrington
Clemson University
mherrin@g.clemson.edu
(863) 258-4758