DATA Step, Macro, Functions and more

When I create a table with left join, only the column headings show. (SAS 9.4)

Reply
New Contributor
Posts: 4

When I create a table with left join, only the column headings show. (SAS 9.4)

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;

Super User
Posts: 23,366

Re: When I create a table with left join, only the column headings show. (SAS 9.4)

Posted in reply to manleygurl

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;


 

Esteemed Advisor
Posts: 5,487

Re: When I create a table with left join, only the column headings show. (SAS 9.4)

Posted in reply to manleygurl

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
Super User
Posts: 5,853

Re: When I create a table with left join, only the column headings show. (SAS 9.4)

Posted in reply to manleygurl

"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
Ask a Question
Discussion stats
  • 3 replies
  • 101 views
  • 0 likes
  • 4 in conversation