Using a data step, I want to include a variable as array parameter.
Why? I want to declare an array, then fill it up with data (the needed length for the array is unknown/can change in the future). My current dataset looks like:
Row1: "val1=x val2=y val3=xx val4=yy" etc.
Row2: "val1=x"
Row3: "val1=x val2=y"
Now, I want to create columns, using an array for the valX read-outs. So a data step is used to count the number of occurrences of "val", which gave me a count column with the number of counts.
(1) Now I want to build an expression like: "array{count}", or "array{max(of count)}"; how can this be achieved? Since array needs an integer input?
(2) Another option would be to create an array{100} and then simply drop columns with only missing values, how can this be achieved?
Sample of the data step:
data count;
set input;
counter = count(column,'val','i');
run;
data output;
set count;
array Values{100};
do i = 1 to counter;
Values(i) = scan(column,i+1);
end;
run;
array myarray {*} val: ;. If you are creating variables, you may need to use one step to compute the number of variables to create, and store that in a macro variable, then in separate step usearray myarray{&maxcount}...data count; set input; counter = count(column,'val','i'); run; data output; set count; array Values{100}; do i = 1 to counter; Values(i) = scan(column,i+1); end; run;&maxcountgave me the same result: array expected an integer, or a *.