Date: Wed, 22 Apr 2009 10:35:54 -0700
Reply-To: "Kenneth M. Lin" <kenneth_m_lin@SBCGLOBAL.NET>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Kenneth M. Lin" <kenneth_m_lin@SBCGLOBAL.NET>
Organization: at&t http://my.att.net/
Subject: Re: Variable definition trouble
Instead of using track name as a variable name, you should set up a table
like this
track avg_purse
ALB 12
...
Then you could merge that list into the main dataset by matching track1
against track. Then you will have
purse1= purse1 * (avg_purse / AP);
regardless of what track1 is.
"Michael Bryce Herrington" <mherrin@G.CLEMSON.EDU> wrote in message
news:e52cf8710904220836p37415d2di363e06b979ef398f@mail.gmail.com...
> Hey,
>
> I am trying to set up something like a Consumer price index, but I need it
> to be defined differently depending upon the location. I can do this
> manually track by track, but I feel like you all may have a much smarter
> and
> efficient way of doing so. Here is the set up:
>
> This deals with racing data. (the second option below may be the better
> way
> to do this)
> I have a data set (class) with the track, date, purse values, etc... set
> up
> for all the tracks. We are trying to compare horses moving from one track
> to another using an index of the average purse value over the last year.
> Due to the large number of tracks this would be very time consuming to do
> so
> like I mentioned above. I have shortened my code below for simplicity.
>
> *
>
> data* class;
>
> set class;
>
> *this will define the average purse value for each track;
>
> ALB=*12*; AQU=*40*; ARP=*9*; AP=*28*; ASD=*10*; ATL=*22*; ATO=*12*;
>
> BM=*18*; BMF=*16*; BEL=*59*; BEU=*4*; CRC=*19*; CBY=*15*; CT=*19*;
>
> CD=*41*; DNL=*23*; CLS=*6*; DMR=*60*; DEL=*28*; DED=*21*; ELP=*13*;
> *
>
> run*;
>
> *establish a data set for one track only;
>
> *it would be nice to skip this but it is ok;
> *
>
> data* ap;
>
> set class;
>
> if track='AP';
> *
>
> run*;
>
> *track1 and purse1 are values from the previous race the
>
> horse competed in;
> *
>
> data* ap;
>
> set ap;
>
> if track1='ALB' then purse1=purse1*(ALB/AP);
>
> if track1='AQU' then purse1=purse1*(AQU/AP);
>
> if track1='ARP' then purse1=purse1*(ARP/AP);
>
> if track1='AP' then purse1=purse1*(AP/AP);
>
> if track1='ASD' then purse1=purse1*(ASD/AP);
>
> if track1='ATL' then purse1=purse1*(ATL/AP);
>
> if track1='ATO' then purse1=purse1*(ATO/AP);
>
> etc.;
> *
>
> RUN*;
>
>
>
> Another option would be to make one variable that is the purse index.
> There
> is a variable in 'class' called track1, track1 resolves as the abbr. track
> name, the track name is now a variable that resolves to the avg purse size
> which I need to use to create the purse index.
>
>
> *
>
> data* class;
>
> set class;
>
> *this will define the average purse value for each track;
>
> ALB=*12*; AQU=*40*; ARP=*9*; AP=*28*; ASD=*10*; ATL=*22*; ATO=*12*;
>
> BM=*18*; BMF=*16*; BEL=*59*; BEU=*4*; CRC=*19*; CBY=*15*; CT=*19*;
>
> CD=*41*; DNL=*23*; CLS=*6*; DMR=*60*; DEL=*28*; DED=*21*; ELP=*13*;
> *
>
> run*;
> *
>
> data* class;
>
> set class;
>
> *I would need the value of the value of track1 and track
>
> i.e. track=AP, and above we define AP=28 and track1=CD=41;
>
> PurseIndex=track1/track;
>
> *I would want this to resolve to 41/28=1.46;
>
> *Is this possible?;
>
> purse1=purse1*PurseIndex;
> *
>
> run*;
> Thanks!!!
>
> --
> Bryce Herrington
> Clemson University
> 111 Briar Lane
> Central, SC 29630
> mherrin@g.clemson.edu
> (863) 258-4758
|