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

ds1

S_id Sname S_Subject
1am
2bs
3ce

 

ds2

S_id Sname S_subject
1aas
2bs
3ace

 

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_idds2_id Ds1_name ds2_nameds1_S_subjectds2_
11aaams
22bbss
33cacee

another table is old values and update values

recdss_idS_name S_subject
old1am
new1aas
old3ce
new3ace

anyone can help above problem?

1 ACCEPTED SOLUTION

Accepted Solutions
sas_university
Obsidian | Level 7
hi sir thanks for the help
, as your help i got desired out put ,
but want1 data set update values in highlighted in anyone color.

View solution in original post

4 REPLIES 4
sas_university
Obsidian | Level 7

below  both tables expacted output

ds1_idds2_id Ds1_name ds2_nameds1_S_subjectds2_S_SUBJECT
11aaams
22bbss
33cacee

second table

recdss_idS_name S_subject
old1am
new1aas
old3ce
new3ace

 

PeterClemmensen
Tourmaline | Level 20

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;
sas_university
Obsidian | Level 7
hi sir thanks for the help
, as your help i got desired out put ,
but want1 data set update values in highlighted in anyone color.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 4 replies
  • 713 views
  • 1 like
  • 2 in conversation