I have a job content object in my SAS Viya 4 Visual Analytics report and the dropdown list should be populated by a promoted table which lives in for report users accessible caslib LAB. But whatever I do or if I hardcode thje caslib as lab or mycas, the available tables are from the caslib DEV. I do not why. Here the code from the job content.
/* sas code*/
%global lookback_criteria lookback_days lookback_samples plant_list;
/* Conditionally Init CAS library; */
%if doIExist^= %sysfunc(sessfound(mySession)) %then %do;
cas mySession sessopts=(caslib=lab timeout=1800 locale="en_US");
caslib _all_ assign;
%end;
%let outtable=ALL_LAB_NOM;
libname mycas cas caslib="LAB";
/* --------------------------------------------------------------------
Initialize accumulators
-------------------------------------------------------------------- */
%let plantList=;
%let newRankVar=;
/* --------------------------------------------------------------------
Case detection:
- If plant_LIST_COUNT exists and >0 → use plant_LIST1...plant_LISTn
- Else → use plant_LIST as single or space-separated list
-------------------------------------------------------------------- */
/* Normalize plant_LIST just in case */
%let plant_LIST=%sysfunc(compbl(&plant_LIST));
%put &plant_LIST;
%if %symexist(plant_LIST_COUNT) and %superq(plant_LIST_COUNT) ne %then %do;
/* ---------- CASE: UI sent indexed plant_LIST1...plant_LISTn ---------- */
%macro plants_selected;
%local i this;
%do i = 1 %to &plant_list_count;
/* %let this=&&plant_LIST&i; */
%let this=%str(%')&&plant_LIST&i.%str(%');
/* Append to plantList */
%let plantList=&plantList &this;
%end;
%mend;
%end;
%else %do;
/* ---------- CASE: UI sent only plant_LIST (1 or more, space-separated) ---------- */
/* %let plant_list_count=%sysfunc(countw(&plant_LIST,%str( ))); */
%macro plants_selected;
%local i this;
/* %let this=&&plant_LIST&i; */
%let this=%str(%')&plant_LIST%str(%');
/* Append to plantList */
%let plantList=&this;
%mend;
%end;
%plants_selected;
/* Debug output */
%put NOTE: Final plantList = &plantList;
%let spaces=^{unicode 00A0}^{unicode 00A0}^{unicode 00A0}^{unicode 00A0}^{unicode 00A0};
ods escapechar='^';
proc odstext;
p "01. ^{style[textdecoration=underline fontsize=20pt]
Plant and time window customized LIMS LIVE DATA table} ^{newline 2} ^{style[color=black fontsize=16pt ]
&spaces VA has difficulties in handling huge tables. ^{newline 1}
&spaces Limiting the scope helps a lot to speed up the report reponsiveness.
} ^{newline 2}";
p "02. ^{style[textdecoration=underline fontsize=18pt]Table information:} ^{newline 2}";
run;
%let casy=ALL_LAB_NOM_EXT;
%let liby=dev;
%let liby2=casuser;
/* helper macros */
%macro nameunique(abrev=);
%global temptab;
%let temptab=%sysfunc(cats( %sysfunc(substrn(%sysfunc(compress(&abrev, , kadf)), 1, 15)), %sysfunc(compress(%sysfunc(putn(%sysfunc(datetime()), best29.)), '.'))));
%mend;
%nameunique(abrev=my_lims);
%let _plant=NOME;
cas mysession sessopts=(caslib="&liby");
proc cas;
table.tableExists result=e status=rc /
caslib = "&liby"
name = "&casy"
;
/* If the data exists, set dataExists = 1 and grab the current report data */
if(e.exists ^= 0) then do;
source myDataStep;
data &liby..&temptab;
set &liby..&casy;
where plant_code in (&plantList);
run;
endsource;
/* Execute the DATA step code from the source block named myDataStep */
dataStep.runCode result=r status=rc /
code=myDataStep;
end;
/* If the data exists, set dataExists = 1 and grab the current report data */
if(e.exists = 0) then do;
table.loadtable / path="&casy..sashdat" casOut="&temptab" caslib="&liby";
/* table.promote /name="&casy" ; */
print "hello";
end;
run;
/* Add a position variable that reflects datetime order within the logical group samplepoint_desc, product_name, test_name_complete */
proc cas;
session mysession;
simple.groupByInfo result=r /
includeDuplicates=true,
minFrequency=1,
groupByLimit=1000M, includemissing=true,
generatedColumns={"POSITION"},
noVars=false,
/* COPYVARS={ */
/* "plant_code"}, */
casOut={name="&temptab._a", replace=TRUE, CASLIB="&liby"},
table={ groupBy={"plant_code"}, name="&temptab", CASLIB="&liby",
computedVars={{
name="_sample_date_time"}},
computedVarsProgram="_sample_date_time=-sample_date_time;",
orderBy={"plant_code", "_sample_date_time"}, groupByMode="REDISTRIBUTE", where="1=1"};
run;
data _null_;
if index("&lookback_criteria", 'days') then call symputx('whereclause', catx(' ', "datepart(sample_date_time) >= intnx('days', today(), -&lookback_days)"), 'G');
if ^index("&lookback_criteria", 'days') then call symputx('whereclause', catx(' ', "&lookback_samples >= _position_"), 'G');
run;
%put "&whereclause";
proc casutil;
droptable casdata="&CASY._cust" incaslib="&liby2" quiet;
run;
cas mysession sessopts=(caslib="&liby2");
data &liby2..&casy._cust;
set &liby..&temptab._a;
where &whereclause;
run;
proc cas;
table.recordcount result=r / table={name="&casy._cust" caslib="&liby2"};
x=symputx('rowcnt', r.recordcount[1,1], 'G');
run;
%macro exiter;
/* Guard clause */
%if %sysevalf(&rowcnt=0) %then %do;
%goto skipped;
%end;
%let DEST_LIB=&liby2; /* The CAS library where the destination data should go */
%let DEST_DATA=&casy._CUST; /* The CAS table name where the destination data should go, UPCASE!!! */
proc casutil;
Save casdata="&DEST_DATA" incaslib="&DEST_LIB" casout="&DEST_DATA%str(.)sashdat" outcaslib="&DEST_LIB" replace ;
Quit;
proc casutil;
droptable casdata="&DEST_DATA" incaslib="&liby2" quiet;
run;
cas mysession sessopts=(caslib="&liby2");
proc cas;
table.tableExists result=e status=rc /
caslib = "&liby2"
name = "&DEST_DATA"
;
/* If the data exists, set dataExists = 1 and grab the current report data */
if(e.exists = 0) then do;
table.loadtable / path="&DEST_DATA..sashdat" casOut="&DEST_DATA" ;
table.promote /name="&DEST_DATA" ;
print "hello";
end;
run;
proc cas;
table.fetch table="&DEST_DATA" sortby={{name="plant_code" order='ASCENDING'}, {name="_position_" order='ASCENDING'}};
run;
proc cas;
table.columninfo / table={name="&DEST_DATA."};
table.recordcount / table={name="&DEST_DATA."};
table.tabledetails / name="&DEST_DATA.";
table.tableinfo / name="&DEST_DATA.";
simple.distinct / table={name="&DEST_DATA."};
simple.numrows / table={name="&DEST_DATA."};
simple.mdsummary / table={name="&DEST_DATA."};
/* simple.summary / table={name="&DEST_DATA."}; */
simple.topk / table={name="&DEST_DATA."} includeMissing=false includemisc=false topk=3 bottomk=3;
run;
%goto prevented;
%skipped:
proc odstext;
p "^{style[color=red fontsize=28pt ]
&spaces NOTE: Filters too restrictive. ^{newline 1}
&spaces No rows have passed through.
} ^{newline 2}";
run;
%prevented:
%mend;
%exiter;
/* step prompt json */
{
"showPageContentOnly": true,
"pages": [
{
"id": "page1",
"type": "page",
"label": "Filter selection",
"children": [
{
"id": "inputtable1",
"type": "inputtable",
"label": "Table for plant selection",
"required": true,
"placeholder": "",
"visible": true,
"readonly": false
},
{
"id": "columnselector1",
"type": "columnselector",
"label": "Define plant_code as column",
"include": null,
"order": true,
"columntype": "a",
"max": 1,
"min": 1,
"visible": false,
"readonly": true,
"table": "inputtable1"
},
{
"id": "plant_list",
"type": "list",
"label": "Select plant(s) to include",
"items": {
"ref": "columnselector1"
},
"max": null,
"min": 1,
"visible": ""
},
{
"id": "lookback_criteria",
"type": "dropdown",
"label": "Choose lookback criteria",
"items": [
{
"value": "By last X days"
},
{
"value": "By last X samples"
}
],
"required": true,
"placeholder": "",
"visible": ""
},
{
"id": "section1",
"type": "section",
"label": "Numeric filters",
"open": true,
"children": [
{
"id": "section2",
"type": "section",
"label": "Explanation for filter logic",
"open": false,
"visible": "",
"children": [
{
"id": "text1",
"type": "text",
"text": "Filter behavior: \nEach filter you set applies independently to the data. The filters do not adjust or recalculate each other — instead, they combine to further restrict the final selection.\n\nDays or samples filter limits the data to the chosen time or last samples window.\n\nFrequency filter enforces a minimum spacing between samples.\n\nMinimum sample count requires at least the specified number of samples.\n\nBecause these filters are multiplicative, the final subset may be smaller than expected. For example, if you choose 10 days, 24‑hour frequency, and 100 minimum samples, the time and frequency filters may only allow ~10 samples, which cannot meet the minimum count requirement.",
"visible": ""
}
]
},
{
"id": "lookback_days",
"type": "dropdown",
"label": "Include last X days",
"items": [
{
"value": "90"
},
{
"value": "180"
},
{
"value": "365"
},
{
"value": "730"
}
],
"required": true,
"placeholder": "",
"visible": [
"$lookback_criteria",
"=",
"By last X days"
]
},
{
"id": "lookback_samples",
"type": "numstepper",
"label": "Include last X samples",
"required": true,
"integer": true,
"min": 20,
"max": 1000,
"stepsize": 1,
"visible": [
"$lookback_criteria",
"!=",
"By last X days"
]
}
]
}
]
}
],
"values": {
"inputtable1": {
"library": "LAB",
/* "library": "MYCAS", DOES NOT WORK EITHER */
"table": "PLANT_FILTER"
},
"columnselector1": [
{
"value": "plant_code"
}
],
"plant_list": [],
"lookback_criteria": {
"value": "By last X days"
},
"lookback_days": {
"value": "365"
},
"lookback_samples": 300
}
}
The MYCAS points to the DEV caslib, I do not understand why this happens. Or how to fix it.
The step prompt UI uses the Compute REST API to get available tables and libraries and starts up a standard compute session for that. To have the CAS tables available in the compute session you will need to assign the libname xyz cas ...; statements in the autoexec of the compute context. In your case this should be the SAS Job Execution compute context.
The step prompt UI uses the Compute REST API to get available tables and libraries and starts up a standard compute session for that. To have the CAS tables available in the compute session you will need to assign the libname xyz cas ...; statements in the autoexec of the compute context. In your case this should be the SAS Job Execution compute context.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.