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

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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