Now I'm stuck with this error:
ERROR: The %DO statement is not valid in open code.
This is the full code of what I have right now:
LIBNAME CONX BASE "/sas_perm_data/Enlighten_Landing" ;
%global s;
/** Passthrough SQL to load distinct service category types ***/
proc sql;
connect to odbc as myconn (dsn=Enlighten);
create table ServiceCategories as
select *
from connection to myconn (
select distinct
cb_cntr_service_category.service_cat_desc as ServiceCat
from
cb_subs_prod_pckg as orig
left outer join cb_cntr_service_type on
orig.service_type_code = cb_cntr_service_type.service_type_code
left outer join cb_cntr_service_category on
cb_cntr_service_category.service_cat_code = cb_cntr_service_type.service_cat_code
);
quit;
/** Passthrough SQL to load possible units ***/
proc sql;
connect to odbc as myconn (dsn=Enlighten);
create table PossibleUnits as
select *
from connection to myconn (
select distinct unit_pk from cb_so_unit
);
quit;
/**Load service categories into numbered macro variables*/
proc sql noprint;
select servicecat into :Services1 - :Services20
from ServiceCategories;
quit;
%let cntservices=&sqlobs; /*count of services */
/**Load units into numbered macro variables*/
proc sql noprint;
select unit_pk into :Units1 - :Units70000
from PossibleUnits;
quit;
%let cntunits=&sqlobs; /* Count of units */
/*Create table to hold returned values*/
proc sql noprint;
create table test (unit_pk num, service_cat_desc char(30), so_pk num, pk num);
quit;
/**Loop through all possible units and service categories and insert into table*/
proc sql;
%do s=1 %to &cntservices; /* just through services for now for testing*/
insert into test
select
orig.unit_pk,
orig.service_cat_desc,
orig.so_pk,
min(orig.sub_prod_pckg_pk) as pk
from
conx.subscriber_services as orig
where
orig.so_pk is not null and
orig.unit_pk = 54 and
orig.service_cat_desc = &&Services&s
group by
orig.unit_pk,
orig.service_cat_desc,
orig.so_pk
order by
orig.unit_pk,
orig.service_cat_desc,
pk
;
%end;
quit;
I think I'm just a few lines away from getting this problem solved.
more
Message was edited by: SteveONCSU
... View more