options symbolgen mlogic mprint;
data &InputParam/*(keep = Info Wafers_1 CO1-CO10)*/;
format Info Wafers_1 CO1-CO10;
set Recipe_transp;
Nr = countc(COL1,'+');
CALL SYMPUT('Nummer', Nr);
array CO{10} $50.;
do L = 1 to Nr;
CO{L} = scan(COL1,L,'+');
end;
Info = "&InputParam";
run;
what i want to do is replace the CO{10} by CO{Nr} but i dont know how?
Not quite sure what you are trying to do. Does it approximately something like the following?:
data have;
informat COL1 $30.;
input COL1;
cards;
+3+4+5
+2
+1+2+3+4+5
;
proc sql noprint;
select max(countc(COL1,'+')) into : nummer
from have;
quit;
data want;
set have;
array CO{&nummer.} $50.;
L=1;
do while (scan(COL1,L,'+') ne "");
CO{L} = scan(COL1,L,'+');
L+1;
end;
run;
well i gues it solves my problem, as i want to make sure of the exact number of CO (columns). But after all it is a dataset so the maximum is OK for this.
But is there a way to make a different Nummer for each single row in my dataset because now i always count to the max
As long as you initially set the array high enough to capture all values, there are numerous ways to limit the number of iterations.
For example, the method I used, the method you originall used, a slight variant of that method:
do l=1 to countc(COL1,'+');
and many others.
Two things to note: the array dimensions are set just once and you can't access a macro variable you create from within the datastep it is created.
Just write as
array CO{nr} $50.;
cann't it work?
or use a data _null_ before your data step to make a macro variable "call symputx(....)",
then use this macro variable to instead of 10.
Ksharp
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.