I want to define a string in a PROC IML
, say "aaaaa" (five "a").
In a DATA
step, I would use the repeat()
function, which creates a string repeating substrings, as explained in the documentation.
data _null_;
x=repeat('a',4); /* string with five 'a' */
put x;
run;
However, in SAS/IML, the repeat()
function is different : it creates a matrix repeating elements of another one (documentation here).
So if I use this function, I will get a vector with five "a" elements.
proc iml;
x=repeat('a',5); /* 5 'a' strings */
print x;
quit;
In that example, I could obviously not bother and go directly with :
x="aaaaa";
But what if I needed a larger string (say 100 "a" for example) ? I could also create it outside of the PROC IML
and import it after but there must be a more clever way to address the problem, isn't there ?