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 |
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
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
Thank you so much.
It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.
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.
Ready to level-up your skills? Choose your own adventure.