BookmarkSubscribeRSS Feed
Ai2
Calcite | Level 5 Ai2
Calcite | Level 5

Hi All,

 

I am using SAS Customer Intelligence Studio (6.5) and would like to know if there is a way to get Business Context name or ID in custom STP or process node? Maybe there is global macro variable which could be used? 

 

2 REPLIES 2
Dmitry_Alergant
Pyrite | Level 9

There is no direct way to do that as far as I am aware.

 

As a practical matter, we'd sometimes create two logical Stored Processes that can be powered by the same .sas script and define one of the STP parameters (macro variables) to be a constant, different between two instances. Then one business context has one Stored Process leveraged as a Custom Diagram Tool on a panel, and another business context has another. So, you are duplicating metadata definitions, but you can avoid duplicating the actual program code (.sas).

 

If you are dead set on "getting a Business Context name" from inside the stored process (process node), a possible dirty workaround can be to define different MATable libraries for every business context. You can then use SAS BASE language facilities (DICTIONARY.LIBNAMES) to get the information on details of how MATables libname is assigned in the current session (what path or options, etc), and deduct what was the business context based on that. This is a really dirty hack that you should not be doing unless there is absolutely no other way. I wonder that a use case for that may be.

 

Hope this helps.

 

 

-------
Dmitriy Alergant, Tier One Analytics
JamesAnderson
SAS Employee

As Dmitry has said, there is no easy way, so all we have is workarounds for this.

Adding to Dmitry’s suggestions, a couple more possible options depending on how you have implemented MA:

  1. If the Subject Name is unique across your business contexts, then you can use this as a proxy for Business Context, and there are 2 macro variables that could be checked in the STP: OUTSUBJECTNAME or INSUBJECTNAME
  2. (this is my preferred one) The Campaign Code *should* be unique across business contexts (although this is not always true, in my experience its unlikely that a campaign code is used in the same campaign in 2 business contexts in the same CI install, or even more rarely in the same CDM). In which case the Business Context can be retrieved from the CDM based upon the campaign code and some PROC SQL. This method relies on the campaign being published first (which for execution is always true assuming you have a CDM). Once you have the BC name you can then check that you have only 1 or return an error to the user.

 

%macro GetBC;
proc sql noprint;
	select value into :libval
	from &matableformacro
	where name = 'CICOMMON_LIBNAME';
quit;

&libval;
%let CDMLibref = %scan(&libval, 2);

proc sql noprint;
	SELECT 	business_context_nm,
			count(distinct(business_context_nm)) into :bc_name, :bc_count
	FROM &CDMLibref..CI_CAMPAIGN
	WHERE CAMPAIGN_CD = %tslit(&CAMPCODE);
quit;
%let bc_count = &bc_count;

%if %NRQUOTE(&bc_count) eq %NRQUOTE(0) %then %do ;
  %** Campaign isnt in the CDM! ;
  %let MAMsg=Error. The &CINODENAME node failed to execute successfully. The campaign was not found in the CDM. Please publish the campaign;
  %let SYSCC=12 ;
  %mastatus(&_stpwork.status.txt) ;
  %return ;
%end ;

%if %NRQUOTE(&bc_count) ne %NRQUOTE(1) %then %do ;
  %** Duplicates or something else is wrong! ;
  %let MAMsg=Error. The &CINODENAME node failed to execute successfully. More than one Business Context found;
  %let SYSCC=12 ;
  %mastatus(&_stpwork.status.txt) ;
  %return ;
%end ;
%if %NRQUOTE(&bc_count) eq %NRQUOTE(1) %then %do ;
  %PUT Campaign executing in &bc_name business context; 
%end ;
%mend;
%GetBC;
How to improve email deliverability

SAS' Peter Ansbacher shows you how to use the dashboard in SAS Customer Intelligence 360 for better results.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 1256 views
  • 0 likes
  • 3 in conversation