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

Hi every one.

Now I have dataset A:

Date AZWMTG
1/1/2015203050
1/2/2015***
1/3/2015***
1/4/2015***
1/5/2015***
1/6/2015***
1/7/2015***
1/8/2015***

Now I have dataset B:

Date AZWMTG
1/1/201510012

I want dataset A look like:

Date AZWMTG
1/1/201510012
1/2/2015***
1/3/2015***
1/4/2015***
1/5/2015***
1/6/2015***
1/7/2015***
1/8/2015***

Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
DBailey
Lapis Lazuli | Level 10

proc sql;

update dataset_a t1

set

     az=(select az from dataset_b where date=t1.date),

     wm=(select wm from dataset_b where date=t1.date),

     tg = (select tg from dataset_b where date=t1.date)

where exists (select * from dataset_b where date=t1.date);

quit;

View solution in original post

5 REPLIES 5
DBailey
Lapis Lazuli | Level 10

proc sql;

update dataset_a t1

set

     az=(select az from dataset_b where date=t1.date),

     wm=(select wm from dataset_b where date=t1.date),

     tg = (select tg from dataset_b where date=t1.date)

where exists (select * from dataset_b where date=t1.date);

quit;

jjjunyi
Calcite | Level 5

thanks but looks some error

jjjunyi
Calcite | Level 5

Never mind, I forgot to delete comma.

Tom
Super User Tom
Super User

Not sure why people insist on putting commas at the end of the line instead of the beginning.  They are much harder to see out there.

Ksharp
Super User

Since you already have a index variable DATE, why not use MERGE statement.

data want;
 merge A B;
 by date;
run;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 4419 views
  • 0 likes
  • 4 in conversation