I tried just running your sample code with the 3 tables of created data (A,B and C) that did include the value we are trying to find.
I closed all SAS instances and tried running it again. When I did. It threw this error--
ERROR: Invocation of unresolved module ISEMPTY.
25 proc iml;
NOTE: Writing HTML Body file: sashtml.htm
NOTE: IML Ready
26 dsn='work.'+datasets('work');
26 ! /*Change to your libname*/
27 do i=1 to nrow(dsn);
28 use (dsn[i]);
29 read all var _char_ into x[c=vnames];
29 ! /*Seach chars*/
30 flag=(find(x,'123')^=0);
30 ! /*Change to the value you want to find*/
31 do j=1 to nrow(flag);
32 loc=loc(flag[j,]);
33 if ^isempty(loc) then do;
34 temp=vnames[loc];
35 vname=vname//temp;
36 obs=obs//repeat(j,nrow(temp));
37 table=table//repeat(dsn[i],nrow(temp));
38 end;
39 end;
40
41 read all var _num_ into x[c=vnames];
41 ! /*Seach numbers*/
42 flag=(x=123);
42 ! /*Change to the value you want to find*/
43 do j=1 to nrow(flag);
44 loc=loc(flag[j,]);
45 if ^isempty(loc) then do;
46 temp=vnames[loc];
47 vname=vname//temp;
48 obs=obs//repeat(j,nrow(temp));
49 table=table//repeat(dsn[i],nrow(temp));
50 end;
51 end;
52 close (dsn[i]);
53 end;
ERROR: Invocation of unresolved module ISEMPTY.
If I delete the empty dataset 'Want' and run it again, I get a different error:
135 proc iml;
NOTE: IML Ready
136 dsn='work.'+datasets('work');
136! /*Change to your libname*/
137 do i=1 to nrow(dsn);
138 use (dsn[i]);
139 read all var _char_ into x[c=vnames];
139! /*Seach chars*/
140 flag=(find(x,'123')^=0);
140! /*Change to the value you want to find*/
141 do j=1 to nrow(flag);
142 loc=loc(flag[j,]);
143 if ^isempty(loc) then do;
144 temp=vnames[loc];
145 vname=vname//temp;
146 obs=obs//repeat(j,nrow(temp));
147 table=table//repeat(dsn[i],nrow(temp));
148 end;
149 end;
150
151 read all var _num_ into x[c=vnames];
151! /*Seach numbers*/
152 flag=(x=123);
152! /*Change to the value you want to find*/
153 do j=1 to nrow(flag);
154 loc=loc(flag[j,]);
155 if ^isempty(loc) then do;
156 temp=vnames[loc];
157 vname=vname//temp;
158 obs=obs//repeat(j,nrow(temp));
159 table=table//repeat(dsn[i],nrow(temp));
160 end;
161 end;
162 close (dsn[i]);
163 end;
ERROR: File WORK.WANT.DATA does not exist.
statement : USE at line 138 column 1
And if I leave the empty dataset 'Want' and try running it again, I get this error:
171
172 proc iml;
NOTE: IML Ready
173 dsn='work.'+datasets('work');
173! /*Change to your libname*/
174 do i=1 to nrow(dsn);
175 use (dsn[i]);
176 read all var _char_ into x[c=vnames];
176! /*Seach chars*/
177 flag=(find(x,'123')^=0);
177! /*Change to the value you want to find*/
178 do j=1 to nrow(flag);
179 loc=loc(flag[j,]);
180 if ^isempty(loc) then do;
181 temp=vnames[loc];
182 vname=vname//temp;
183 obs=obs//repeat(j,nrow(temp));
184 table=table//repeat(dsn[i],nrow(temp));
185 end;
186 end;
187
188 read all var _num_ into x[c=vnames];
188! /*Seach numbers*/
189 flag=(x=123);
189! /*Change to the value you want to find*/
190 do j=1 to nrow(flag);
191 loc=loc(flag[j,]);
192 if ^isempty(loc) then do;
193 temp=vnames[loc];
194 vname=vname//temp;
195 obs=obs//repeat(j,nrow(temp));
196 table=table//repeat(dsn[i],nrow(temp));
197 end;
198 end;
199 close (dsn[i]);
200 end;
WARNING: Data set WORK.WANT is empty.
statement : USE at line 175 column 1
WARNING: End of File reached.
statement : READ at line 176 column 2
ERROR: (execution) Module not loaded, operation not available.
operation : FIND at line 177 column 12
operands : x, *LIT1004
x 0 row 0 col (type ?, size 0)
*LIT1004 1 row 1 col (character, size 3)
123
statement : ASSIGN at line 177 column 2
... View more