BookmarkSubscribeRSS Feed
Lopes
Calcite | Level 5

How can I join to datasets and keep all the variables in dataset1 and from dataset2 only the ones that are not in dataset1.

This tables change all the time so if I do the query and join tables, the next time I do it the ones that where in dataset1 are no longer there and I need to get them from dataset2.

Thanks.

4 REPLIES 4
ballardw
Super User

Can you share some of the generated code?

It may be as simple as the order of listing your data sets in the join but some example code and input / output would clarify your issue and want.

Reeza
Super User

Do you join on all the fields that are match between the two files, or is there a chance that the same fields could differ between tables?

If they're all the same, then try doing a Natural Join, though you may have to code that, instead of using the Query Tool. I'm not sure.

TomKari
Onyx | Level 15

Does it have to be done using EG tasks, or can you use SAS code?

Tom

Lopes
Calcite | Level 5

I  can use SAS code.

I need to join to tables, the columns in table 1 changes all the time and I need to get always all the columns from table 1 and the ones from table to that are not in table 1.

PROC SQL;

   CREATE TABLE WORK.xxx(label="QUERY_FOR_CONTABILIDAD") AS

   SELECT t1.xxx1,

          t1.xxx2,

   t1.xxx3,

          t2.xxx11,

   t2.xxx4

        

      FROM WORK.QUERY_FOR_CONTABILIDAD_0001 t1

           INNER JOIN WORK.COPIA_DE_LISTADO_DE_CUENTAS_CONT t2 ON (t1.Cuenta_contable = t2.CUENTA);

   

QUIT;

The idea es

I hope this more clear.

Thanks!

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 988 views
  • 0 likes
  • 4 in conversation