Hello, i want create a vector of all options from vector of strings : i have to "multiply" every cell to other cell
example :
i have a variable of characters
a
b
d
e
i want to create the next variable
ab
ad
ae
bd
be
de
how i can do it?
thank you
Normally in SAS you work an datasets not "vectors". So if we create your input as a single variable dataset.
data have ;
length letter $1 ;
input letter @@;
cards;
a b d e
;;;;
Then we can create your new single variable dataset from that using a DO loop and POINT= option on SET statement.
data want ;
length next_variable $2 ;
set have ;
do p=_n_+1 to nobs ;
set have (rename=(letter=next_letter)) nobs=nobs point=p ;
next_variable = cats(letter,next_letter);
output;
end;
keep next_variable ;
run;
This question seems to be for SQL.
data have ;
length letter $1 ;
input letter @@;
cards;
a b d e
;;;;
run;
proc sql;
create table want as
select cats(a.letter,b.letter) as new_letter
from have as a,have as b
where a.letter lt b.letter;
quit;
Xia Keshan
Message was edited by: xia keshan
Xie, agree thar SQL is a nice choice for this. But to comply withe requirement I think you need to change NE to GT.
Opps. Thanks Linus. Code has been updated. I think ARRAY maybe is a better choice .
If the actual data set is large, yes. But for normal data I think SQL is easier.
But if there is not order out there, SQL would NOT work , Like something:
b
a
c
-->
ba
bc
ac
消息编辑者为:xia keshan
Maybe you want combination. Example straight out of SAS online documentation for LEXCOMB
thank you, that what i need. can you please the meaning of of x
x
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 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.