Hi, I tried making changes suggested. It should be pointed out that the Set learn.expose only has years between 1944 and 1948. I changed the years in the array to reflect this. Now I am getting an 'array subscription out of range error. Below, I have included my code, then the data set learn.expose, and finally, the error log. Thanks! Libname Review'/folders/myfolders/Review' ;
Libname Learn'/folders/myfolders/Learn' ;
Libname myformat'/folders/myfolders/sasuser.v94' ;
Options fmtsearch=(myformat) ;
/*Creating a Multidimensional Array*/
Data Review.Benzene_Levels ;
Array Level{1945:1948,5} ; /*populates two dimensional array*/
If _n_ = 1 then
Do year = 1944 to 1948 ;
Do Job = 1 to 5 ;
Input Level{Year,Job} @ ;
End ;
End ;
Set learn.expose ;
Job = Input(Translate(Jobcode,'12345', 'ABCDE'), 1.) ; /*translates Jobcode to Job*/
Benzene = Level{Year,Job} ; /*Defines Benzene variable at a confluence of Year and Job*/
Drop Job ;
Datalines ;
220 180 210 110 90
202 170 208 100 85
150 110 150 60 50
105 56 88 40 20
45 22 22 10 8
;
Proc print data=Review.Benzene_Levels noobs ;
run ; data learn.expose;
input Worker $ Year JobCode : $1.;
datalines;
001 1944 B
002 1948 E
003 1947 C
005 1945 A
006 1948 D
; Errors (1)
ERROR: Array subscript out of range at line 73 column 7.
Warnings (2)
Notes (9)
1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
61
62 Libname Review'/folders/myfolders/Review' ;
NOTE: Libref REVIEW was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/Review
63 Libname Learn'/folders/myfolders/Learn' ;
NOTE: Libref LEARN refers to the same physical library as LEARN2.
NOTE: Libref LEARN was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/Learn
64 Libname myformat'/folders/myfolders/sasuser.v94' ;
NOTE: Libref MYFORMAT refers to the same physical library as SASUSER.
NOTE: Libref MYFORMAT was successfully assigned as follows:
Engine: V9
Physical Name: /folders/myfolders/sasuser.v94
65 Options fmtsearch=(myformat) ;
66
67 /*Creating a Multidimensional Array*/
68 Data Review.Benzene_Levels ;
69 Array Level{1945:1948,5} ; /*populates two dimensional array*/
70 If _n_ = 1 then
71 Do year = 1944 to 1948 ;
72 Do Job = 1 to 5 ;
73 Input Level{Year,Job} @ ;
74 End ;
75 End ;
76 Set learn.expose ;
77 Job = Input(Translate(Jobcode,'12345', 'ABCDE'), 1.) ; /*translates Jobcode to Job*/
78 Benzene = Level{Year,Job} ; /*Defines Benzene variable at a confluence of Year and Job*/
79 Drop Job ;
80 Datalines ;
ERROR: Array subscript out of range at line 73 column 7.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
81 220 180 210 110 90
Level1=. Level2=. Level3=. Level4=. Level5=. Level6=. Level7=. Level8=. Level9=. Level10=. Level11=. Level12=. Level13=. Level14=.
Level15=. Level16=. Level17=. Level18=. Level19=. Level20=. year=1944 Job=1 Worker= JobCode= Benzene=. _ERROR_=1 _N_=1
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set REVIEW.BENZENE_LEVELS may be incomplete. When this step was stopped there were 0 observations and 24
variables.
WARNING: Data set REVIEW.BENZENE_LEVELS was not replaced because this step was stopped.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
86 ;
87
88 Proc print data=Review.Benzene_Levels noobs ;
89 run ;
NOTE: No observations in data set REVIEW.BENZENE_LEVELS.
NOTE: PROCEDURE PRINT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
90
91 /* Data learn.look_up ;
92 array level{1944:1949,5} _temporary_;
93 if _n_ = 1 then do Year = 1944 to 1949;
94 do Job = 1 to 5;
95 input level{Year,Job} @;
96 end;
97 end;
98
99 set learn.expose;
100 Job = input(translate(Jobcode,'12345','ABCDE'),1.);
101 Benzene = level{Year,Job};
102 drop Job;
103 datalines;
104 220 180 210 110 90
105 202 170 208 100 85
106 150 110 150 60 50
107 105 56 88 40 30
108 60 30 40 20 10
109 45 22 22 10 8
110 ;
111
112 Proc print data=learn.look_up noobs ;
113 run ; */
114
115 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
128
... View more