BookmarkSubscribeRSS Feed
manleygurl
Calcite | Level 5

Here is my code below. It appears that the two files join but only the Column headings show from the second dataset. I'm also attaching a screen shot of the "joined" file. I'm using SAS 9.4.  Thanks

 


proc sql undo_policy = none;
     create table FinalBharReg as select
     a.*, b.*
     from fundaBETABhar a left join ControlsBhar b
     on a.gvkey= b.gvkey2 and a.datadate= b.datadate2;
quit;

4 REPLIES 4
Reeza
Super User

No screenshot was attached. 

 

That usually happens when your join condition is wrong and you have no matches, so everything shows up as missing. 

Check the fields you're joining and see if they match exactly or if you need to change something. For example if its a character variable, are they both the same lengths.

Also make sure to check the log.

 


@manleygurl wrote:

Here is my code below. It appears that the two files join but only the Column headings show from the second dataset. I'm also attaching a screen shot of the "joined" file. I'm using SAS 9.4.  Thanks

 


proc sql undo_policy = none;
     create table FinalBharReg as select
     a.*, b.*
     from fundaBETABhar a left join ControlsBhar b
     on a.gvkey= b.gvkey2 and a.datadate= b.datadate2;
quit;


 

PGStats
Opal | Level 21

It means that the condition

 

gvkey= b.gvkey2 and a.datadate= b.datadate2

 

is never met. If you replace left join by inner join, the output table should be empty.

 

One of many possible reasons for this would be that the dates have different representations in both tables.

PG
LinusH
Tourmaline | Level 20

"Columns headings" meaning columns, or?

If your tables have the same columns names, yes, they will overwrite (since you are using *) - but you should get a notification in the log if that's the case.

Data never sleeps

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 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.

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