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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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
  • 3352 views
  • 0 likes
  • 4 in conversation