Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Programming
- /
- SAS Procedures
- /
- left join sql do not work

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

☑ This topic is **solved**.
Need further help from the community? Please
sign in and ask a **new** question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 09-23-2022 01:52 PM
(1178 views)

Hello,

when I run the program below there is no error in the log but the variable EPU is empty "."

```
proc sql;
create table test1 as
select Distinct R.*, B.EPU
from test as R
left join EPU_Data as B on R.sas_date=B.sas_date
order by R.Secid, R.sas_date;
quit;
```

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Maybe you imported the dates from somewhere where they are not represented quite the same as in SAS (e.g. Excel)? Happened to me once. The date numbers were not integers. Try:

`left join EPU_Data as B on round(R.sas_date) = round(B.sas_date)`

PG

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

This happens because one (or both) of the following is true:

- Variable EPU is always missing data set B; or
- variable SAS_DATE in data set A never matches the values of SAS_DATE in data set B

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

thanks for the response.

I have the same data format for sas_date variable and EPU is not missing there is a number for each data?

I have the same data format for sas_date variable and EPU is not missing there is a number for each data?

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

@sasphd wrote:

I have the same data format for sas_date variable and EPU is not missing there is a number for each data?

Not the format ... the actual values of SAS_DATE don't match.

--

Paige Miller

Paige Miller

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Run this:

```
data test1,
merge
test (in=t)
epu_data (
in=e
keep=sas_date epu
)
;
by sas_date,
if t and e;
run;
```

and then post the complete log (code and messages) from this step.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Maybe you imported the dates from somewhere where they are not represented quite the same as in SAS (e.g. Excel)? Happened to me once. The date numbers were not integers. Try:

`left join EPU_Data as B on round(R.sas_date) = round(B.sas_date)`

PG

**SAS Innovate 2025** is scheduled for May 6-9 in Orlando, FL. Sign up to be **first to learn** about the agenda and registration!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Ready to level-up your skills? Choose your own adventure.