ds1
| S_id | Sname | S_Subject |
| 1 | a | m |
| 2 | b | s |
| 3 | c | e |
ds2
| S_id | Sname | S_subject |
| 1 | aa | s |
| 2 | b | s |
| 3 | ac | e |
i have two data sets one is old data set another one new data set . but have update values
one table like this , two data set upadate values highlight values
| ds1_id | ds2_id | Ds1_name | ds2_name | ds1_S_subject | ds2_ |
| 1 | 1 | a | aa | m | s |
| 2 | 2 | b | b | s | s |
| 3 | 3 | c | ac | e | e |
another table is old values and update values
| recds | s_id | S_name | S_subject |
| old | 1 | a | m |
| new | 1 | aa | s |
| old | 3 | c | e |
| new | 3 | ac | e |
anyone can help above problem?
Do you want both of the posted tables as result?
below both tables expacted output
| ds1_id | ds2_id | Ds1_name | ds2_name | ds1_S_subject | ds2_S_SUBJECT |
| 1 | 1 | a | aa | m | s |
| 2 | 2 | b | b | s | s |
| 3 | 3 | c | ac | e | e |
second table
| recds | s_id | S_name | S_subject |
| old | 1 | a | m |
| new | 1 | aa | s |
| old | 3 | c | e |
| new | 3 | ac | e |
Try this
data ds1;
input S_id Sname $ S_Subject $;
datalines;
1 a m
2 b s
3 c e
;
data ds2;
input S_id Sname $ S_subject $;
datalines;
1 aa s
2 b s
3 ac e
;
data want1;
format ds1_id ds2_id ds1_name ds2_name ds1_Subject ds2_Subject;
merge ds1(rename = (S_id = ds1_id Sname = ds1_name S_Subject = ds1_Subject))
ds2(rename = (S_id = ds2_id Sname = ds2_name S_Subject = ds2_Subject))
;
run;
data want2;
set want1;
if ds1_name ne ds2_name | ds1_Subject ne ds2_Subject then do;
recds = 'old';
Sname = ds1_name;
S_Subject = ds1_Subject;
output;
recds = 'new';
Sname = ds2_name;
S_Subject = ds2_Subject;
output;
end;
keep recds Sname S_Subject;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.