table 1 smb
table 2 test:-
proc sql;
create table test as
select year, product_ID, max(AON) as MAX_AON from class1.smb
group by 1;
quit;
i want to do left join of the smb and test table
so i do this -
proc sql ;
select distinct
(smb.PRODUCT_ID)
,smb.Year
,smb.AON
,smb.CELL_CALL_CNT_M1
,smb.CELL_CALL_CNT_M2
,smb.CELL_CALL_CNT_M3
,smb.CELL_CALL_CNT_M4
,smb.CELL_CALL_CNT_M5
,smb.CELL_CALL_CNT_M6
,smb.CELL_CALL_SEC_M1
,smb.CELL_CALL_SEC_M2
,smb.CELL_CALL_SEC_M3
,smb.CELL_CALL_SEC_M4
,smb.CELL_CALL_SEC_M5
,smb.CELL_CALL_SEC_M6
,smb.CELL_CALL_avg_dur_M1
,smb.CELL_CALL_avg_dur_M2
,smb.CELL_CALL_avg_dur_M3
,smb.CELL_CALL_avg_dur_M4
,smb.CELL_CALL_avg_dur_M5
,smb.CELL_CALL_avg_dur_M6
,smb.CELL_USAGE_CHARGE_AMT_M1
,smb.CELL_USAGE_CHARGE_AMT_M2
,smb.CELL_USAGE_CHARGE_AMT_M3
,smb.CELL_USAGE_CHARGE_AMT_M4
,smb.CELL_USAGE_CHARGE_AMT_M5
,smb.CELL_USAGE_CHARGE_AMT_M6
from class1.smb
left join test
on smb.product_id=test.product_id;
quit;
and this doesn't execute
please help ....
Since you do a left join without using any columns from the "right" dataset, the join makes no sense.
Keep in mind that the distinct forces a sort over all variables, so that could cause heavy processing load.
If it does not do anything, you might have something "unclosed" from previous code that prevents execution.
Anyway, post the log.
If this is a followup to your other message then you have included even less information than before.
There does not appear to be an mistakes in your code (other than extract parentheses around the first variable selected in your longer SQL code). What error are you getting?
Make sure to use one of the two code insert buttons on the menu bar to insert your code and your log. They will pop-up a new window that you can paste in the text from your SAS log window. This way the formatting is preserved.
not executing even . its been running from past 20 min .
change this
(smb.PRODUCT_ID)
to
smb.PRODUCT_ID
that might help.
Still does not execute .executing from past 20 min .
Since you do a left join without using any columns from the "right" dataset, the join makes no sense.
Keep in mind that the distinct forces a sort over all variables, so that could cause heavy processing load.
If it does not do anything, you might have something "unclosed" from previous code that prevents execution.
Anyway, post the log.
the error given is
from class1.smb
left join test.product_id
on smb.product_id=test.product_id;
quit;
i want to know how do i refer this table ,as we refer through libname when we give a path but this is created in proc statement i wrote . How to refer the test table in proc sql to be joined with smb table ?
You refer to dataset test.product_id in your join clause, which means dataset product_id in library test.
now i get new errors i referred the same
Your problems start further up in the code.
I suggest that you spend some time studying the SAS SQL documentation, so you get at least a basic grasp of how the sql procedure works.
Listing all error related to the process would have help at the beginning of this request. Since those important facts were excluded in the beginning time related to resolve the issue was delayed .
yes sure 🙂
but the error now says this :-
Once again: you have to seem absolutely no clue about proc sql, so the complicated things you want to do here are WAY over your head and just a useless waste of time.
Start out with the simple examples from the documentation, and come back once you have that worked out. We're not here to teach you thinngs you can easily learn by yourself by working through Programming 1.
Just this:
77 left join smb.PRODUCT_ID 78 ,smb.Year
The list of variables in a select has to come BEFORE the "from". This is absolutely basic SQL, and you need to grasp that before you advance to any complicated join.
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’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.