BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Songchan
Calcite | Level 5

Hello there,

 

I want to combine two data sets temp03 and temp04 using proc sql select, but it turns out that data set temp04 in my table link is empty.

what's the possible reason of that problem?

 

 

proc sql;
create table link as
select distinct temp03.*,temp04.*
from temp03 as a
left join temp04(where=(linktype in ('LC' 'LU') and
linkprim in ('P' 'C' 'J'))) as b

on a.permno=b.lpermno and b.linkdt<a.date;
quit;

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

The condition b.linkdt<a.date might be a comparison between a datetime value (b.linkdt) and a date value (a.date). try changing to

datepart(b.linkdt) < a.date

PG

View solution in original post

8 REPLIES 8
Reeza
Super User

Remove your WHERE conditions and add them one at a time to see if one is returning an empty table.

 


@Songchan wrote:

Hello there,

 

I want to combine two data sets temp03 and temp04 using proc sql select, but it turns out that data set temp04 in my table link is empty.

what's the possible reason of that problem?

 

 

proc sql;
create table link as
select distinct temp03.*,temp04.*
from temp03 as a
left join temp04(where=(linktype in ('LC' 'LU') and
linkprim in ('P' 'C' 'J'))) as b

on a.permno=b.lpermno and b.linkdt<a.date;
quit;


 

Songchan
Calcite | Level 5

No, still doesn't work

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

I have not seen the data but would this work:

proc sql;
create table link as
select distinct a.*, b.*
from temp03 as a
left join temp04(where=(upcase(linktype) in ('LC' 'LU') and
upcase(linkprim) in ('P' 'C' 'J'))) as b

on a.permno=b.lpermno and b.linkdt<a.date;
quit;
Songchan
Calcite | Level 5

Thanks for replying,

but it still doesn't work

VDD
Ammonite | Level 13 VDD
Ammonite | Level 13

is it posable that b.linkdt <= a.date ?

 

Songchan
Calcite | Level 5
No, still empty for data set temp04
PGStats
Opal | Level 21

The condition b.linkdt<a.date might be a comparison between a datetime value (b.linkdt) and a date value (a.date). try changing to

datepart(b.linkdt) < a.date

PG
Songchan
Calcite | Level 5
Thank you PG! it works!

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
  • 8 replies
  • 1338 views
  • 0 likes
  • 4 in conversation