proc sql;
create table work.test as
select product_ID, max(AON) as MaximumAON from class1.smb
group by 1;
quit;
proc sql ;
select 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
,smb.DATA_CALL_CNT_M1
,smb.DATA_CALL_CNT_M2
,smb.DATA_CALL_CNT_M3
,smb.DATA_CALL_CNT_M4
,smb.DATA_CALL_CNT_M5
,smb.DATA_CALL_CNT_M6
,smb.DATA_CALL_SEC_M1
,smb.DATA_CALL_SEC_M2
,smb.DATA_CALL_SEC_M3
,smb.DATA_CALL_SEC_M4
,smb.DATA_CALL_SEC_M5
,smb.DATA_CALL_SEC_M6
,smb.DATA_CALL_avg_dur_M1
,smb.DATA_CALL_avg_dur_M2
,smb.DATA_CALL_avg_dur_M3
,smb.DATA_CALL_avg_dur_M4
,smb.DATA_CALL_avg_dur_M5
,smb.DATA_CALL_avg_dur_M6
,smb.DATA_USAGE_CHARGE_AMT_M1
,smb.DATA_USAGE_CHARGE_AMT_M2
,smb.DATA_USAGE_CHARGE_AMT_M3
,smb.DATA_USAGE_CHARGE_AMT_M4
,smb.DATA_USAGE_CHARGE_AMT_M5
,smb.DATA_USAGE_CHARGE_AMT_M6
,smb.INT_CALL_CNT_M1
,smb.INT_CALL_CNT_M2
,smb.INT_CALL_CNT_M3
,smb.INT_CALL_CNT_M4
,smb.INT_CALL_CNT_M5
,smb.INT_CALL_CNT_M6
,smb.INT_CALL_SEC_M1
,smb.INT_CALL_SEC_M2
,smb.INT_CALL_SEC_M3
,smb.INT_CALL_SEC_M4
,smb.INT_CALL_SEC_M5
,smb.INT_CALL_SEC_M6
,smb.INT_CALL_avg_dur_M1
,smb.INT_CALL_avg_dur_M2
,smb.INT_CALL_avg_dur_M3
,smb.INT_CALL_avg_dur_M4
,smb.INT_CALL_avg_dur_M5
,smb.INT_CALL_avg_dur_M6
,smb.INT_USAGE_CHARGE_AMT_M1
,smb.INT_USAGE_CHARGE_AMT_M2
,smb.INT_USAGE_CHARGE_AMT_M3
,smb.INT_USAGE_CHARGE_AMT_M4
,smb.INT_USAGE_CHARGE_AMT_M5
,smb.INT_USAGE_CHARGE_AMT_M6
,smb.LOCAL_CALL_CNT_M1
,smb.LOCAL_CALL_CNT_M2
,smb.LOCAL_CALL_CNT_M3
,smb.LOCAL_CALL_CNT_M4
,smb.LOCAL_CALL_CNT_M5
,smb.LOCAL_CALL_CNT_M6
,smb.LOCAL_CALL_SEC_M1
,smb.LOCAL_CALL_SEC_M2
,smb.LOCAL_CALL_SEC_M3
,smb.LOCAL_CALL_SEC_M4
,smb.LOCAL_CALL_SEC_M5
,smb.LOCAL_CALL_SEC_M6
,smb.LOCAL_CAL_avg_dur_M1
,smb.LOCAL_CAL_avg_dur_M2
,smb.LOCAL_CAL_avg_dur_M3
,smb.LOCAL_CAL_avg_dur_M4
,smb.LOCAL_CAL_avg_dur_M5
,smb.LOCAL_CAL_avg_dur_M6
,smb.LOCAL_USAGE_CHARGE_AMT_M1
,smb.LOCAL_USAGE_CHARGE_AMT_M2
,smb.LOCAL_USAGE_CHARGE_AMT_M3
,smb.LOCAL_USAGE_CHARGE_AMT_M4
,smb.LOCAL_USAGE_CHARGE_AMT_M5
,smb.LOCAL_USAGE_CHARGE_AMT_M6
,smb.NAT_CALL_CNT_M1
,smb.NAT_CALL_CNT_M2
,smb.NAT_CALL_CNT_M3
,smb.NAT_CALL_CNT_M4
,smb.NAT_CALL_CNT_M5
,smb.NAT_CALL_CNT_M6
,smb.NAT_CALL_SEC_M1
,smb.NAT_CALL_SEC_M2
,smb.NAT_CALL_SEC_M3
,smb.NAT_CALL_SEC_M4
,smb.NAT_CALL_SEC_M5
,smb.NAT_CALL_SEC_M6
,smb.NAT_CALL_avg_dur_M1
,smb.NAT_CALL_avg_dur_M2
,smb.NAT_CALL_avg_dur_M3
,smb.NAT_CALL_avg_dur_M4
,smb.NAT_CALL_avg_dur_M5
,smb.NAT_CALL_avg_dur_M6
,smb.NAT_USAGE_CHARGE_AMT_M1
,smb.NAT_USAGE_CHARGE_AMT_M2
,smb.NAT_USAGE_CHARGE_AMT_M3
,smb.NAT_USAGE_CHARGE_AMT_M4
,smb.NAT_USAGE_CHARGE_AMT_M5
,smb.NAT_USAGE_CHARGE_AMT_M6
,smb.ONE_TIME_CHARGE_AMT_M1
,smb.ONE_TIME_CHARGE_AMT_M2
,smb.ONE_TIME_CHARGE_AMT_M3
,smb.ONE_TIME_CHARGE_AMT_M4
,smb.ONE_TIME_CHARGE_AMT_M5
,smb.ONE_TIME_CHARGE_AMT_M6
,smb.OTHER_CALL_CNT_M1
,smb.OTHER_CALL_CNT_M2
,smb.OTHER_CALL_CNT_M3
,smb.OTHER_CALL_CNT_M4
,smb.OTHER_CALL_CNT_M5
,smb.OTHER_CALL_CNT_M6
,smb.OTHER_CALL_SEC_M1
,smb.OTHER_CALL_SEC_M2
,smb.OTHER_CALL_SEC_M3
,smb.OTHER_CALL_SEC_M4
,smb.OTHER_CALL_SEC_M5
,smb.OTHER_CALL_SEC_M6
,smb.OTHER_CAL_avg_dur_M1
,smb.OTHER_CAL_avg_dur_M2
,smb.OTHER_CAL_avg_dur_M3
,smb.OTHER_CAL_avg_dur_M4
,smb.OTHER_CAL_avg_dur_M5
,smb.OTHER_CAL_avg_dur_M6
,smb.OTHER_USAGE_CHARGE_AMT_M1
,smb.OTHER_USAGE_CHARGE_AMT_M2
,smb.OTHER_USAGE_CHARGE_AMT_M3
,smb.OTHER_USAGE_CHARGE_AMT_M4
,smb.OTHER_USAGE_CHARGE_AMT_M5
,smb.OTHER_USAGE_CHARGE_AMT_M6
,smb.OVR_CALL_AVG_DURATION_M1
,smb.OVR_CALL_AVG_DURATION_M2
,smb.OVR_CALL_AVG_DURATION_M3
,smb.OVR_CALL_AVG_DURATION_M4
,smb.OVR_CALL_AVG_DURATION_M5
,smb.OVR_CALL_AVG_DURATION_M6
,smb.RECURRING_CHARGE_AMT_M1
,smb.RECURRING_CHARGE_AMT_M2
,smb.RECURRING_CHARGE_AMT_M3
,smb.RECURRING_CHARGE_AMT_M4
,smb.RECURRING_CHARGE_AMT_M5
,smb.RECURRING_CHARGE_AMT_M6
,smb.SPEND_AMT_M1
,smb.SPEND_AMT_M2
,smb.SPEND_AMT_M3
,smb.SPEND_AMT_M4
,smb.SPEND_AMT_M5
,smb.SPEND_AMT_M6
,smb.TOT_CALL_CNT_M1
,smb.TOT_CALL_CNT_M2
,smb.TOT_CALL_CNT_M3
,smb.TOT_CALL_CNT_M4
,smb.TOT_CALL_CNT_M5
,smb.TOT_CALL_CNT_M6
,smb.TOT_CALL_SEC_M1
,smb.TOT_CALL_SEC_M2
,smb.TOT_CALL_SEC_M3
,smb.TOT_CALL_SEC_M4
,smb.TOT_CALL_SEC_M5
,smb.TOT_CALL_SEC_M6
,smb.TOT_CHARGE_AMT_M1
,smb.TOT_CHARGE_AMT_M2
,smb.TOT_CHARGE_AMT_M3
,smb.TOT_CHARGE_AMT_M4
,smb.TOT_CHARGE_AMT_M5
,smb.TOT_CHARGE_AMT_M6
,smb.USAGE_CHARGE_AMT_M1
,smb.USAGE_CHARGE_AMT_M2
,smb.USAGE_CHARGE_AMT_M3
,smb.USAGE_CHARGE_AMT_M4
,smb.USAGE_CHARGE_AMT_M5
,smb.USAGE_CHARGE_AMT_M6
,smb.TCL_DLM
,smb.TCL_DL2M
,smb.TCL_DL3M
,smb.TCH_DLM
,smb.TCH_DL2M
,smb.TCH_DL3M
,smb.LCL_DLM
,smb.LCL_DL2M
,smb.LCL_DL3M
,smb.NCL_DLM
,smb.NCL_DL2M
,smb.NCL_DL3M
,smb.CELL_CALL_SEC_Avg6
,smb.CELL_CALL_avg_dur_Avg6
,smb.CELL_USAGE_CHARGE_AMT_Avg6
,smb.DATA_CALL_CNT_Avg6
,smb.DATA_CALL_SEC_Avg6
,smb.DATA_CALL_avg_dur_Avg6
,smb.DATA_USAGE_CHARGE_AMT_Avg6
,smb.INT_CALL_CNT_Avg6
,smb.INT_CALL_SEC_Avg6
,smb.INT_CALL_avg_dur_Avg6
,smb.INT_USAGE_CHARGE_AMT_Avg6
,smb.LOCAL_CALL_CNT_Avg6
,smb.LOCAL_CALL_SEC_Avg6
,smb.LOCAL_CAL_avg_dur_Avg6
,smb.LOCAL_USAGE_CHARGE_AMT_Avg6
,smb.NAT_CALL_CNT_Avg6
,smb.NAT_CALL_SEC_Avg6
,smb.NAT_CALL_avg_dur_Avg6
,smb.NAT_USAGE_CHARGE_AMT_Avg6
,smb.ONE_TIME_CHARGE_AMT_Avg6
,smb.OTHER_CALL_CNT_Avg6
,smb.OTHER_CALL_SEC_Avg6
,smb.OTHER_CAL_avg_dur_Avg6
,smb.OTHER_USAGE_CHARGE_AMT_Avg6
,smb.OVR_CALL_AVG_DURATION_Avg6
,smb.RECURRING_CHARGE_AMT_Avg6
,smb.SPEND_AMT_Avg6
,smb.TOT_CALL_CNT_Avg6
,smb.TOT_CALL_SEC_Avg6
,smb.TOT_CHARGE_AMT_Avg6
,smb.USAGE_CHARGE_AMT_Avg6
,smb.CELL_CALL_SEC_Avg3
,smb.CELL_CALL_avg_dur_Avg3
,smb.CELL_USAGE_CHARGE_AMT_Avg3
,smb.DATA_CALL_CNT_Avg3
,smb.DATA_CALL_SEC_Avg3
,smb.DATA_CALL_avg_dur_Avg3
,smb.DATA_USAGE_CHARGE_AMT_Avg3
,smb.INT_CALL_CNT_Avg3
,smb.INT_CALL_SEC_Avg3
,smb.INT_CALL_avg_dur_Avg3
,smb.INT_USAGE_CHARGE_AMT_Avg3
,smb.LOCAL_CALL_CNT_Avg3
,smb.LOCAL_CALL_SEC_Avg3
,smb.LOCAL_CAL_avg_dur_Avg3
,smb.LOCAL_USAGE_CHARGE_AMT_Avg3
,smb.NAT_CALL_CNT_Avg3
,smb.NAT_CALL_SEC_Avg3
,smb.NAT_CALL_avg_dur_Avg3
,smb.NAT_USAGE_CHARGE_AMT_Avg3
,smb.ONE_TIME_CHARGE_AMT_Avg3
,smb.OTHER_CALL_CNT_Avg3
,smb.OTHER_CALL_SEC_Avg3
,smb.OTHER_CAL_avg_dur_Avg3
,smb.OTHER_USAGE_CHARGE_AMT_Avg3
,smb.OVR_CALL_AVG_DURATION_Avg3
,smb.RECURRING_CHARGE_AMT_Avg3
,smb.SPEND_AMT_Avg3
,smb.TOT_CALL_CNT_Avg3
,smb.TOT_CALL_SEC_Avg3
,smb.TOT_CHARGE_AMT_Avg3
,smb.USAGE_CHARGE_AMT_Avg3
,smb.CELL_CALL_CNT_DEC2_1
,smb.CELL_CALL_CNT_DEC3_2
,smb.CELL_CALL_CNT_DEC4_3
,smb.CELL_CALL_CNT_DEC5_4
,smb.CELL_CALL_CNT_DEC6_5
,smb.CELL_CALL_SEC_DEC2_1
,smb.CELL_CALL_SEC_DEC3_2
,smb.CELL_CALL_SEC_DEC4_3
,smb.CELL_CALL_SEC_DEC5_4
,smb.CELL_CALL_SEC_DEC6_5
,smb.CELL_CALL_avg_dur_DEC2_1
,smb.CELL_CALL_avg_dur_DEC3_2
,smb.CELL_CALL_avg_dur_DEC4_3
,smb.CELL_CALL_avg_dur_DEC5_4
,smb.CELL_CALL_avg_dur_DEC6_5
,smb.CELL_USAGE_CHARGE_AMT_DEC2_1
,smb.CELL_USAGE_CHARGE_AMT_DEC3_2
,smb.CELL_USAGE_CHARGE_AMT_DEC4_3
,smb.CELL_USAGE_CHARGE_AMT_DEC5_4
,smb.CELL_USAGE_CHARGE_AMT_DEC6_5
,smb.INT_CALL_CNT_DEC2_1
,smb.INT_CALL_CNT_DEC3_2
,smb.INT_CALL_CNT_DEC4_3
,smb.INT_CALL_CNT_DEC5_4
,smb.INT_CALL_CNT_DEC6_5
,smb.INT_CALL_SEC_DEC2_1
,smb.INT_CALL_SEC_DEC3_2
,smb.INT_CALL_SEC_DEC4_3
,smb.INT_CALL_SEC_DEC5_4
,smb.INT_CALL_SEC_DEC6_5
,smb.INT_CALL_avg_dur_DEC2_1
,smb.INT_CALL_avg_dur_DEC3_2
,smb.INT_CALL_avg_dur_DEC4_3
,smb.INT_CALL_avg_dur_DEC5_4
,smb.INT_CALL_avg_dur_DEC6_5
,smb.INT_USAGE_CHARGE_AMT_DEC2_1
,smb.INT_USAGE_CHARGE_AMT_DEC3_2
,smb.INT_USAGE_CHARGE_AMT_DEC4_3
,smb.INT_USAGE_CHARGE_AMT_DEC5_4
,smb.INT_USAGE_CHARGE_AMT_DEC6_5
,smb.LOCAL_CALL_CNT_DEC2_1
,smb.LOCAL_CALL_CNT_DEC3_2
,smb.LOCAL_CALL_CNT_DEC4_3
,smb.LOCAL_CALL_CNT_DEC5_4
,smb.LOCAL_CALL_CNT_DEC6_5
,smb.LOCAL_CALL_SEC_DEC2_1
,smb.LOCAL_CALL_SEC_DEC3_2
,smb.LOCAL_CALL_SEC_DEC4_3
,smb.LOCAL_CALL_SEC_DEC5_4
,smb.LOCAL_CALL_SEC_DEC6_5
,smb.LOCAL_CAL_avg_dur_DEC2_1
,smb.LOCAL_CAL_avg_dur_DEC3_2
,smb.LOCAL_CAL_avg_dur_DEC4_3
,smb.LOCAL_CAL_avg_dur_DEC5_4
,smb.LOCAL_CAL_avg_dur_DEC6_5
,smb.LOCAL_USAGE_CHARGE_AMT_DEC2_1
,smb.LOCAL_USAGE_CHARGE_AMT_DEC3_2
,smb.LOCAL_USAGE_CHARGE_AMT_DEC4_3
,smb.LOCAL_USAGE_CHARGE_AMT_DEC5_4
,smb.LOCAL_USAGE_CHARGE_AMT_DEC6_5
,smb.NAT_CALL_CNT_DEC2_1
,smb.NAT_CALL_CNT_DEC3_2
,smb.NAT_CALL_CNT_DEC4_3
,smb.NAT_CALL_CNT_DEC5_4
,smb.NAT_CALL_CNT_DEC6_5
,smb.NAT_CALL_SEC_DEC2_1
,smb.NAT_CALL_SEC_DEC3_2
,smb.NAT_CALL_SEC_DEC4_3
,smb.NAT_CALL_SEC_DEC5_4
,smb.NAT_CALL_SEC_DEC6_5
,smb.NAT_CALL_avg_dur_DEC2_1
,smb.NAT_CALL_avg_dur_DEC3_2
,smb.NAT_CALL_avg_dur_DEC4_3
,smb.NAT_CALL_avg_dur_DEC5_4
,smb.NAT_CALL_avg_dur_DEC6_5
,smb.NAT_USAGE_CHARGE_AMT_DEC2_1
,smb.NAT_USAGE_CHARGE_AMT_DEC3_2
,smb.NAT_USAGE_CHARGE_AMT_DEC4_3
,smb.NAT_USAGE_CHARGE_AMT_DEC5_4
,smb.NAT_USAGE_CHARGE_AMT_DEC6_5
,smb.SPEND_AMT_DEC2_1
,smb.SPEND_AMT_DEC3_2
,smb.SPEND_AMT_DEC4_3
,smb.SPEND_AMT_DEC5_4
,smb.SPEND_AMT_DEC6_5
,smb.TOT_CALL_CNT_DEC2_1
,smb.TOT_CALL_CNT_DEC3_2
,smb.TOT_CALL_CNT_DEC4_3
,smb.TOT_CALL_CNT_DEC5_4
,smb.TOT_CALL_CNT_DEC6_5
,smb.TOT_CALL_SEC_DEC2_1
,smb.TOT_CALL_SEC_DEC3_2
,smb.TOT_CALL_SEC_DEC4_3
,smb.TOT_CALL_SEC_DEC5_4
,smb.TOT_CALL_SEC_DEC6_5
,smb.TOT_CHARGE_AMT_DEC2_1
,smb.TOT_CHARGE_AMT_DEC3_2
,smb.TOT_CHARGE_AMT_DEC4_3
,smb.TOT_CHARGE_AMT_DEC5_4
,smb.TOT_CHARGE_AMT_DEC6_5
,smb.USAGE_CHARGE_AMT_DEC2_1
,smb.USAGE_CHARGE_AMT_DEC3_2
,smb.USAGE_CHARGE_AMT_DEC4_3
,smb.USAGE_CHARGE_AMT_DEC5_4
,smb.USAGE_CHARGE_AMT_DEC6_5
,smb.Avg_DEC_6M_CELL_CALL_CNT
,smb.Avg_DEC_6M_CELL_CALL_SEC
,smb.Avg_DEC_6M_CELL_CALL_avg_dur
,smb.Avg_DEC_6M_CELL_USAGE_CHARGE_AMT
,smb.Avg_DEC_6M_INT_CALL_CNT
,smb.Avg_DEC_6M_INT_CALL_SEC
,smb.Avg_DEC_6M_INT_CALL_avg_dur
,smb.Avg_DEC_6M_INT_USAGE_CHARGE_AMT
,smb.Avg_DEC_6M_LOCAL_CALL_CNT
,smb.Avg_DEC_6M_LOCAL_CALL_SEC
,smb.Avg_DEC_6M_LOCAL_CAL_avg_dur
,smb.Avg_DEC_6M_LOC_USAGE_CHRG_AMT
,smb.Avg_DEC_6M_NAT_CALL_CNT
,smb.Avg_DEC_6M_NAT_CALL_SEC
,smb.Avg_DEC_6M_NAT_CALL_avg_dur
,smb.Avg_DEC_6M_NAT_USAGE_CHARGE_AMT
,smb.Avg_DEC_6M_SPEND_AMT
,smb.Avg_DEC_6M_TOT_CALL_CNT
,smb.Avg_DEC_6M_TOT_CALL_SEC
,smb.Avg_DEC_6M_TOT_CHARGE_AMT
,smb.Avg_DEC_6M_USAGE_CHARGE_AMT
,smb.Avg_DEC_3M_CELL_CALL_CNT
,smb.Avg_DEC_3M_CELL_CALL_SEC
,smb.Avg_DEC_3M_CELL_CALL_avg_dur
,smb.Avg_DEC_3M_CELL_USAGE_CHARGE_AMT
,smb.Avg_DEC_3M_INT_CALL_CNT
,smb.Avg_DEC_3M_INT_CALL_SEC
,smb.Avg_DEC_3M_INT_CALL_avg_dur
,smb.Avg_DEC_3M_INT_USAGE_CHARGE_AMT
,smb.Avg_DEC_3M_LOCAL_CALL_CNT
,smb.Avg_DEC_3M_LOCAL_CALL_SEC
,smb.Avg_DEC_3M_LOCAL_CAL_avg_dur
,smb.Avg_DEC_3M_LOC_USAGE_CHRG_AMT
,smb.Avg_DEC_3M_NAT_CALL_CNT
,smb.Avg_DEC_3M_NAT_CALL_SEC
,smb.Avg_DEC_3M_NAT_CALL_avg_dur
,smb.Avg_DEC_3M_NAT_USAGE_CHARGE_AMT
,smb.Avg_DEC_3M_SPEND_AMT
,smb.Avg_DEC_3M_TOT_CALL_CNT
,smb.Avg_DEC_3M_TOT_CALL_SEC
,smb.Avg_DEC_3M_TOT_CHARGE_AMT
,smb.Avg_DEC_3M_USAGE_CHARGE_AMT from class1.smb
left join test
on smb.product_id=test.product_id;
quit;
error is given as follows:-
if you do a test run by dumping all the extra columns and just select 2 or 3 columns for your second SQL process you might be-able to debug it.
After you have the logic working add back into the code all the extra information
https://communities.sas.com/t5/SAS-Studio/please-see-the-error/m-p/543764
i want to perform left join of smb file and the test file created in proc sql.
first proc sql is executing fine
i need to know how do i refer the table created in first proc sql (test) in the second proc sql.
Considering this result:
I really like the long descriptive names they assist those who don't know that dataset variables are
While those long names are getting in your way because the code is hard as he?? to read.
why don't you use a simple data step to create a subset of the data information needed?
do you have to use Proc SQL because it has to be done on a SQL server?
i am using these datasets as they are in my assignments 😞
i need to use proc sql ony in this
if you do a test run by dumping all the extra columns and just select 2 or 3 columns for your second SQL process you might be-able to debug it.
After you have the logic working add back into the code all the extra information
https://communities.sas.com/t5/SAS-Studio/please-see-the-error/m-p/543764
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.