Hi,
I am very new to sas an trying to search within a concatenated var ("COMBINATION") which is in the form (product1 + product2 + product 3) for any part of the previously used combination. I am trying to establish how many changes in combinations are a complete change (vs an addition to an existing regimen);
data completley_new_products;
set combination_products;
by cust_id combination;
lag_combination= lag(combination);
where combination not contains lag_combination;
run;
Any help or guidance much appreciated!
It is not clear what you have and what you expect as result. So please follow the guidelines and include data in usable form, see How to convert datasets to data steps for details.
You will probably have to split the new combination into the various product codes, and check them one by one, something like:
data completely_new_products;
set combination_products;
by cust_id combination;
lag_combination= lag(combination);
if not first.cust_id then do _N_=1 to countw(combination);
if indexw(lag_combination,scan(combination,_N_)) then
delete;
end;
run;
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!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.