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: Save the Date

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

Save the date!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 2 replies
  • 1129 views
  • 0 likes
  • 2 in conversation