Hi, I need to create a new variable consisting of three values 1, 2 and 3 and apply to all values to an already existing variable.
This is what I have:
A
B
C
This is what I need:
A 1
A 2
A 3
B 1
B 2
B 3
C 1
C 2
C 3
I realize this is probably an easy fix, but I can't figure it out.
Thanks for your help 🙂
just loop each record
data want;
set have;
do newvar=1 to 3;
output;
end;
run;
just loop each record
data want;
set have;
do newvar=1 to 3;
output;
end;
run;
data have;
input var1 $;
datalines;
A
B
C
;
data want;
set have;
do var2=1 to 3;
output;
end;
run;
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.