Date: Tue, 19 Aug 2008 14:34:27 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>"
<schreier.junk.mail@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>"
<schreier.junk.mail@GMAIL.COM>
Subject: Re: How to merge two unmatched datasets
On Tue, 19 Aug 2008 06:27:47 -0400, Bill Behrens <mngorgeman@GMAIL.COM> wrote:
>Sorry, I should have been more specific, with your code I am getting the
>following
>
>WARNING: Multiple lengths were specified for the BY variable teamname by
>input data sets. This may
> cause unexpected results.
This WARNING arises because you have TEAMNAME with a default length of 8 in
PRICES and a length of 3 specified by the informat in GAMES.
>ERROR: Array subscript out of range at line 3496 column 12.
>date=. weekday=. teamname=ARI p1994=27.69 p1995=31.97 p1996=35.49
>p1997=39.65 p1998=39.65 p1999=40.1
>p2000=39.65 p2001=37.6 p2002=33.68 p2003=35.99 p2004=39.72 p2005=44.98
>p2006=51.32 p2007=57.59
>FIRST.teamname=1 LAST.teamname=1 price=. _ERROR_=1 _N_=3449
This is a data problem, at runtime. You have a missing value for DATE which
propagates through the INTNX and YEAR functions. Either fix the data or make
the assignment statement for PRICE conditional.
>
>I am running the following code
>
>data prices;
>input teamname $ p1994 - p2007;
>cards;
>ARI 27.69 31.970 35.490 39.650 39.650 40.100 39.650 37.600
>33.680 35.990 39.720 44.980 51.320 57.59
>ATL 27 32.230 31.490 31.490 32.150 40.100 40.420 39.140
>29.780 34.630 43.710 52.670 60.360 66.59
>BAL . . 35.680 37.440 42.930 42.750 42.750 50.140
>50.140 53.030 53.030 62.010 66.140 76.94
>BUF 33.46 33.460 33.460 35.580 35.580 40.890 46.060 46.060
>37.610 42.550 37.130 39.370 41.290 46.46
>CAR . 37.920 39.260 55.470 55.470 55.450 57.920 60.300
>42.270 42.270 50.230 54.860 61.440 60.19
>CHI 32.23 35.100 38.180 38.180 38.180 38.180 42.700 42.700
>51.420 65.000 65.560 68.890 77.780 76.28
>CIN 28.99 31.990 34.090 34.090 37.770 37.770 56.210 56.210
>47.310 47.280 52.130 55.720 62.030 66.05
>CLE 27.27 32.610 . . . 44.660 43.760 45.000
>43.090 45.710 45.710 48.790 48.790 48.54
>DAL 32.85 38.250 38.250 37.590 43.480 47.900 47.900 50.010
>50.000 53.060 53.060 66.200 72.780 84.42
>DEN 32.34 33.060 35.830 35.830 35.830 46.400 46.400 77.410
>52.500 57.280 61.180 63.940 68.400 71.93
>DET 29.1 28.540 33.700 35.430 35.790 35.650 39.050 39.050
>50.230 53.910 56.630 56.900 60.000 59.01
>GNB 26.13 26.130 30.610 36.510 36.510 42.570 48.460 53.510
>50.730 54.400 54.400 56.130 58.390 63.39
>HOO 31.46 31.320 31.330 . . . . .
>50.990 50.670 56.170 56.730 57.750 60.66
>IND 26.48 28.180 31.760 34.150 34.150 42.090 46.980 54.550
>46.770 47.390 54.350 60.060 66.420 71.32
>JAC . 36.590 36.590 54.240 56.710 56.710 60.700 62.850
>62.850 62.850 40.800 40.160 45.080 45.19
>KAN 29.16 31.220 34.200 38.020 41.980 41.690 46.150 52.180
>54.470 58.400 67.260 66.490 72.580 73.92
>MIA 29.65 32.560 35.330 42.160 42.160 43.590 45.100 56.340
>45.830 46.460 48.510 51.960 55.000 66.11
>MIN 29.79 33.940 36.950 33.050 35.740 44.620 48.280 52.650
>56.370 59.000 61.630 67.940 71.000 71.81
>NWE 34.22 34.220 34.210 39.450 39.450 39.450 47.770 47.770
>76.190 75.330 75.330 90.890 90.890 90.91
>NOR 26.71 32.170 34.840 34.820 34.470 41.960 45.560 49.880
>46.320 43.870 42.360 51.310 55.000 56.42
>NYG 35.59 35.590 35.590 40.910 40.910 45.900 45.900 55.930
>56.470 61.670 66.670 71.590 76.590 80.97
>NYJ 25 25.000 25.330 30.500 35.920 41.500 51.480 57.160
>57.200 62.200 66.390 71.320 74.960 79.87
>OAK . 51.410 51.410 52.840 52.840 51.680 51.740 51.740
>58.890 58.890 58.890 58.890 62.380 61.19
>PHI 40 40.000 42.830 42.830 37.590 37.590 43.890 46.190
>46.190 64.000 61.910 66.090 69.000 76.73
>PIT 30.71 30.710 35.760 35.760 35.760 40.760 40.760 62.030
>49.830 54.550 54.550 59.190 59.190 66.00
>SDG 34.27 37.960 38.960 53.870 53.870 53.870 58.550 58.550
>46.820 46.820 46.820 54.820 62.820 74.82
>SFO 39.75 39.750 45.000 45.000 50.000 50.000 50.000 50.000
>58.000 58.000 64.000 64.000 63.700 59.07
>SEA 28 28.000 34.140 32.650 33.950 35.680 44.210 44.970
>43.280 43.060 42.800 44.780 50.460 62.37
>STL . 33.610 33.570 33.980 33.980 33.990 42.840 49.590
>52.370 54.920 57.860 60.920 63.500 68.28
>TAM 29.57 29.730 33.060 35.460 64.580 64.650 67.490 70.610
>44.410 49.780 59.380 63.590 68.000 69.71
>TEN . . . 40.750 45.110 55.630 59.330 60.940
>40.660 43.350 45.770 47.820 47.820 54.09
>WAS 35.7 35.700 35.690 52.920 62.070 62.070 81.890 81.890
>68.060 68.060 68.120 67.530 79.130 88.59
>;
>run;
>
>data games;
>input date mmddyy10. weekday teamname $3. ;
>cards;
>9/11/1994 7 ARI
>10/2/1994 7 ARI
>10/23/1994 7 ARI
>10/30/1994 7 ARI
>11/20/1994 7 ARI
>11/27/1994 7 ARI
>12/11/1994 7 ARI
>12/18/1994 7 ARI
>9/10/1995 7 ARI
>10/1/1995 7 ARI
>10/15/1995 7 ARI
>10/29/1995 7 ARI
>11/12/1995 7 ARI
>11/26/1995 7 ARI
>.
>.
>.
>.
>.
>12/10/2006 7 WAS
>12/30/2006 6 WAS
>9/9/2007 7 WAS
>9/23/2007 7 WAS
>10/7/2007 7 WAS
>10/21/2007 7 WAS
>11/11/2007 7 WAS
>12/2/2007 7 WAS
>12/6/2007 4 WAS
>12/30/2007 7 WAS
>;
>run;
>
>data need( keep = date weekday teamname price);
> merge games prices;
> by teamname;
> array p(1994:2007) p1994-p2007;
> price = p( year( intnx('year.3',date,0) ) );
> run;
>
>=====================================================================
>
>With Muthia's code I get the following:
>
>WARNING: The variable price in the DROP, KEEP, or RENAME list has never
>been referenced
>
>NOTE: There were 32 observations read from the data set WORK.YEARLY.
>NOTE: There were 3448 observations read from the data set WORK.WEEKLY.
>NOTE: The data set WORK.NEED has 0 observations and 19 variables.
>
>
>I am using the above extended data that includes all the teams and years
>between 1994-2007. I added the other teams to Muthia's if-else code.
>
> Bill