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

Sample Data:

I would like to know how to copy values of MILK from B to C

OBSABC
1COFFEE$16.80$16.80
2COFFEE$27.14$27.14
3COFFEE$49.20$49.20
4COFFEE$65.00$65.00
5COFFEE$66.70$66.70
6MILK$38.46$0.00
7MILK$128.20$0.00
8MILK$66.50$0.00
9MILK$32.05$0.00
10MILK$30.06$0.00
11MILK$14.85$0.00
12TEA$34.60$34.60
13TEA$1.73$1.73
14TEA$70.93$70.93
15TEA$6.92$6.92
16EXPRESSO$34.60$0.00
17EXPRESSO$10.38$0.00
18EXPRESSO$17.30$0.00

 

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
data want;
set have;

if a = 'MILK' then C = B;

run;

You can use a conditional IF statement. 

 


@Gladis6680 wrote:

Sample Data:

I would like to know how to copy values of MILK from B to C

OBS A B C
1 COFFEE $16.80 $16.80
2 COFFEE $27.14 $27.14
3 COFFEE $49.20 $49.20
4 COFFEE $65.00 $65.00
5 COFFEE $66.70 $66.70
6 MILK $38.46 $0.00
7 MILK $128.20 $0.00
8 MILK $66.50 $0.00
9 MILK $32.05 $0.00
10 MILK $30.06 $0.00
11 MILK $14.85 $0.00
12 TEA $34.60 $34.60
13 TEA $1.73 $1.73
14 TEA $70.93 $70.93
15 TEA $6.92 $6.92
16 EXPRESSO $34.60 $0.00
17 EXPRESSO $10.38 $0.00
18 EXPRESSO $17.30 $0.00

 


 

View solution in original post

2 REPLIES 2
Reeza
Super User
data want;
set have;

if a = 'MILK' then C = B;

run;

You can use a conditional IF statement. 

 


@Gladis6680 wrote:

Sample Data:

I would like to know how to copy values of MILK from B to C

OBS A B C
1 COFFEE $16.80 $16.80
2 COFFEE $27.14 $27.14
3 COFFEE $49.20 $49.20
4 COFFEE $65.00 $65.00
5 COFFEE $66.70 $66.70
6 MILK $38.46 $0.00
7 MILK $128.20 $0.00
8 MILK $66.50 $0.00
9 MILK $32.05 $0.00
10 MILK $30.06 $0.00
11 MILK $14.85 $0.00
12 TEA $34.60 $34.60
13 TEA $1.73 $1.73
14 TEA $70.93 $70.93
15 TEA $6.92 $6.92
16 EXPRESSO $34.60 $0.00
17 EXPRESSO $10.38 $0.00
18 EXPRESSO $17.30 $0.00

 


 

Gladis6680
Obsidian | Level 7

Thank you so much.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 374 views
  • 0 likes
  • 2 in conversation