| Date: | Wed, 21 Dec 2011 14:24:42 -0500 |
| Reply-To: | Stanley Luo <shanminglo@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Stanley Luo <shanminglo@GMAIL.COM> |
| Subject: | Re: Lookup tables |
|
Thank for your kindly help & suggestion!!!
I'll explain again :)
I have dataset A whith 3 cols, area, start_date, eval_date, respectively.
Now, i want to know what is the rate of start_date and eval_date according
to the dataset B
For example, the start_rate of obs 1 should be 129.44 and 109.93 of
eval_rate, which lookup from dataset B.
dataset A
area start_date eval_date start_rate eval_rate
TP 1996Q2 2002Q2 129.44 109.93
TP 1997Q1 1999Q1
TP 1997Q2 1998Q4
TP 1997Q3 2002Q1
KS 1995Q4 2002Q1 122.36 95.35
KS 1995Q4 2004Q4
KS 1996Q1 2001Q2
KS 1995Q4 2002Q2
KS 1996Q1 2004Q4
KS 1996Q1 2000Q4
KS 1996Q2 2001Q4
KS 1996Q2 1999Q2
KS 1996Q3 2003Q1
KS 1996Q3 1999Q2
KS 1996Q3 2003Q2
dataset B
Quarter TP KS
1991Q3 114.50 116.56
1991Q4 118.37 118.45
1992Q1 121.98 124.39
1992Q2 126.11 128.08
1992Q3 128.86 125.32
1992Q4 127.43 128.40
1993Q1 127.26 130.63
1993Q2 128.03 129.57
1993Q3 134.08 135.02
1993Q4 132.88 129.12
1994Q1 134.22 133.94
1994Q2 137.64 130.38
1994Q3 136.66 131.02
1994Q4 136.58 128.79
1995Q1 131.33 129.72
1995Q2 133.25 126.64
1995Q3 129.93 123.67
1995Q4 122.88 122.36
1996Q1 123.90 121.18
1996Q2 129.44 122.73
1996Q3 130.79 123.48
1996Q4 129.76 124.90
1997Q1 129.55 119.85
1997Q2 130.92 120.66
1997Q3 133.51 122.49
1997Q4 137.90 124.41
1998Q1 128.5 113.49
1998Q2 123.99 113.55
1998Q3 121.72 108.3
1998Q4 119.96 107.75
1999Q1 119.05 103.44
1999Q2 118.45 105.08
1999Q3 122.76 102.86
1999Q4 115.03 104.38
2000Q1 117.22 102.85
2000Q2 116.44 103.54
2000Q3 117.7 99.56
2000Q4 109.75 97.52
2001Q1 110.39 98.48
2001Q2 106.59 93.37
2001Q3 104.27 92.45
2001Q4 105.93 93.1
2002Q1 105.62 95.35
2002Q2 109.93 96.51
2002Q3 105.11 95.16
2002Q4 107.91 97.6
2003Q1 111.05 98.71
2003Q2 105.21 96.34
2003Q3 115.73 103.13
2003Q4 115.95 104.33
2004Q1 121.66 109.89
2004Q2 127.18 114.95
2004Q3 128.9 113.57
2004Q4 132.08 120.51
2005Q1 133.96 121.88
2005Q2 139.87 123.47
2005Q3 141.47 126.74
2005Q4 145.45 130.03
Best Regards,
On Wed, 21 Dec 2011 11:06:52 -0800, Fareeza Khurshed <fkhurshed@GMAIL.COM>
wrote:
>SAS has a year Quarter format, ie YYQ6. will give you the fomrat you need,
>assuming you have a date variable.
>
>Since the data shown doesn't line up, its hard to guess what you want the
>output to really be, but my guess is a PROC SQL left join is what you're
>looking for, from dataset a to dataset b.
>
>If you can provide some better data where the output matches the example it
>would be easier to help. Your variables don't seem to line up across the
>datasets, ie where does start_rate and evaluate_rate come from. Also only
>one obs is actually in your sample dataset (2001Q1) so there would be a lot
>of assumptions going on for what you actually want.
>
>Cheers,
>Fareeza
>
>
>On Wed, Dec 21, 2011 at 10:16 AM, Stanley Luo <shanminglo@gmail.com> wrote:
>
>> Dear SAS-Ls:
>> I have following 2 questions:
>> 1.How do I convert date to "quarter" format?
>> for example, 2011/7/4 converts to "2011Q3", 2011/10/10 to "2011Q4" since
i
>> got lots of "quarters".
>>
>> 2.Follow Question 1, I have two datasets,
>>
>> dataset A:
>> obs Area start_date evaluate_date
>> 1 tp 2003Q2 2007Q3
>> 2 ks 2001Q1 2004Q4
>> .
>> .
>> .
>>
>>
>> dataset B:
>> obs tp ks
>> 2001Q1 109.19 109.63
>> 2001Q2 112.52 115.13
>> 2001Q3 116.33 118.55
>> 2001Q4 118.86 115.99
>> .
>> .
>> .
>>
>>
>> I need A to lookup B which desired result is as below:
>> obs Area start_date evaluate_date start_rate evaluate_rare
>> 1 tp 2003Q2 2007Q3 115.99 120.06
>> 2 ks 2001Q1 2004Q4 109.63 110.89
>>
>> How do I make it happen??
>> Thanks in advace!!!
>>
|