Is it possible to get all combinations of two word string in SAS and print it in log
E.g. My string is always
Codes find
And I want output like
Codes Find
cOdes fInd
CoDeS fiNd
.
.
.
Like this. My string contains 2 words. First word of 5 letters then a blank space and then 4 letter word.
I know that we can use regex for this . But somehow I am unable to get it solved.
Many thanks in advance
Not really. PRX is hard for this, But easy for data step:
data have; string='Codes find'; run; data _null_; set have; call symputx('n',length(string)); run; data want; set have; array x{&n}; n=dim(x); k=-1; nsubs=2**n; do i=1 to nsubs; string=lowcase(string); rc=graycode(k, of x{*}); do j=1 to dim(x); if x{j}=1 then substr(string,j,1)=upcase(substr(string,j,1)); end; output; end; keep string; run;
Xia Keshan
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.