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

Hello everyone 

I have run the following code 

proc sql; 
create table me AS SELECT a.n_cfo,a.n_prod,a.n_disexp,b.Is_there_any_defect_in_internal,c.Fraud_Dummy
from real as a, defect as b
full join violation as c
on a.code=b.code=c.code and a.year=b.year=c.year;
quit;

but i got the following message


62 proc sql;
63 create table me AS SELECT
63 ! a.n_cfo,a.n_prod,a.n_disexp,b.Is_there_any_defect_in_internal,c.Fraud_Dummy
64 from real as a, defect as b
65 full join violation as c
66 on a.code=b.code=c.code and a.year=b.year=c.year;
ERROR: Correlated reference to column code is not contained within a subquery.
ERROR: Correlated reference to column year is not contained within a subquery.
67 quit;
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.02 seconds
cpu time 0.03 seconds

###

so i do not know where the error i checked my data very well 

please explain such an error.

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

I can't see your data, so this is untested, but I think this gives you what you want

 

proc sql; 
create table me AS SELECT a.n_cfo,a.n_prod,a.n_disexp,b.Is_there_any_defect_in_internal,c.Fraud_Dummy
from real as a, defect as b
where a.code=b.code and a.year=b.year
full join violation as c
on b.code=c.code and b.year=c.year;
quit;

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

I can't see your data, so this is untested, but I think this gives you what you want

 

proc sql; 
create table me AS SELECT a.n_cfo,a.n_prod,a.n_disexp,b.Is_there_any_defect_in_internal,c.Fraud_Dummy
from real as a, defect as b
where a.code=b.code and a.year=b.year
full join violation as c
on b.code=c.code and b.year=c.year;
quit;
Radwan
Quartz | Level 8

but this option removes the codes that do not exist in the last file.

for instance: the last file contains 1500 firms code and the rest contain 1900 

so this option ((where) without full join) will eliminate 400 codes  

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

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
  • 2 replies
  • 1109 views
  • 0 likes
  • 2 in conversation