Hi,
Thanks for using a data step to provide the data, that helps.
I would agree with others that some context would help as to why you require a particular observation to be loaded into an array. If you could explain this then you might be presented with another approach that is considered better practice.
Having said that, the following code might be one way you could try it (array statement copied from @Patrick).
NB. The use of the stop statement can help prevent a data step from running infinitely when the point= option is being used.
data have;
infile DATALINES dsd missover;
input varr1 varr2 varr3;
CARDS;
1, 2, 3
2, 3, 4
5, 4
4, 3
9, 4, 1
6,
;
%let obs_num = 2;
data want(drop = i);
array myarr{*} varr1 - varr3;
obs_num = &obs_num;
set have point = obs_num;
do i = 1 to dim(myarr);
put myarr[i]=;
end;
output;
/* use stop as point= option is being used */
stop;
run;
The log shows:
85 %let obs_num = 2;
86
87 data want(drop = i);
88 array myarr{*} varr1 - varr3;
89 obs_num = &obs_num;
90 set have point = obs_num;
91
92 do i = 1 to dim(myarr);
93 put myarr[i]=;
94 end;
95
96 output;
97 stop;
98 run;
varr1=2
varr2=3
varr3=4
NOTE: The data set WORK.WANT has 1 observations and 3 variables.
Thanks & kind regards,
Amir.
... View more