BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
KatLinden
Obsidian | Level 7

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 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

just loop each record

 

data want;
set have;
do newvar=1 to 3;
 output;
end;
run;

View solution in original post

2 REPLIES 2
novinosrin
Tourmaline | Level 20

just loop each record

 

data want;
set have;
do newvar=1 to 3;
 output;
end;
run;
PeterClemmensen
Tourmaline | Level 20
data have;
input var1 $;
datalines;
A
B
C
;

data want;
   set have;
   do var2=1 to 3;
      output;
   end;
run;

AI Navigator GIF.gif


Navigate AI governance with SAS tools for compliance and ethical AI practices. Try SAS Ai Navigator for free for the first six months.

Check it out on Microsoft Marketplace →

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1794 views
  • 1 like
  • 3 in conversation