I followed through this article to re-build successfully the job with a prompt from Visual Analytics in SAS Viya 4.
But for my context I need to access caslib tables and not the sashelp.cars table.
So my attempt is to promote a table CARS in the casuser caslib and refer to this one.
But the the table is not recognized while the prompt fires.
Here's my try so far.
%global selectMake;
%put &selectmake.;
cas mySession sessopts=(caslib=casuser timeout=1800 locale="en_US");
caslib _all_ assign;
cas mySession sessopts=(caslib="casuser");
libname MYCAS cas caslib='casuser';
proc sql;
create table work.cars as
select Make, Model, Type, MSRP from mycas.cars
where Make = "&selectMake"
order by MSRP desc;
quit;
title "Top Five Most Expensive: &selectMake";
proc print data=work.cars(obs=5);
run;
title;
title "MSRP by Type: &selectMake";
proc sgplot data=work.cars;
vbar type / response=MSRP stat=mean;
run;
title;
I've replaced the library value with CASUSER as well, but the error persists.
And in the job config I've changed to ' _CONTEXTNAME=CAS Management service compute context'.
The log is free of errors, but I cannot manage to populate the dropdown list.
It sounds like you may still be having an issue assigning the caslib to your compute context. Make sure whatever table you want to use to populate your drop-down list is a global table, and then make sure that the libname statement creating a libref to the caslib has been added as an autoexec statement to the appropriate compute context. I worked up an example using the PUBLIC caslib and the SAS Job Execution compute context, so mine looks like this:
Then I created pretty much the same UI as you - I have a table selector that points to public.cars, a read-only column pointing to the Make column, and a drop-down list that will be populated with Make from public.cars:
Then I can add the job to the job content object:
And I'll get the dynamic drop-down list:
I've tried as well to add cas context to the json prompt, without success.
I've seen this value in the json from Visual Analytics Reports.
From Visual Analytics there are no caslibs available, and I've tried many of the compute contexts.
@GregTreiman @XavierBizoux , @Stu_SAS can you help me out?
Hi @acordes. You need to make sure that you've assigned the caslib you want to use to the compute context that is associated with the job. You can do this in Environment Manager - here's some a link to some more info: SAS Help Center: Working with Dynamic Data in Prompts and HTML Forms
In your case, it sounds like you would just need to add a libname autoexec statement to the CAS Management service compute context.
Thanks Xavier and @GregTreiman ,
your advice seems promising, but although I have admin rights and can access Environment Manager I'm reluctant to making any changes there because I am not at all an expert in this field.
Am I on the right track? I suppose the change is a two liner, but I do not know if it's under add property and how the syntax should look like.
In Environment Manager, click on the Contexts tab. Then use the drop down to pick Compute contexts:
Then select he context you're using and hit the Edit button in the top right.
Click the Advanced tab and then enter your libname statement in the bottom field:
Let me know if this helps!
I get to this point!
Then I enter the following line without ";".
Libname mycas cas caslib=”public”
But it does nothing despite saving without notes.
I don't understand the autoexec context. In SAS Studio I would start my code like this:
cas mySession sessopts=(caslib=casuser timeout=1800 locale="en_US");
caslib _all_ assign;
ibname mycas cas caslib='public';
An autoexec statement just means that it will run automatically at start up. You won't see anything happen when you save it. The purpose of adding this libname statement is to make the data that you want to use available to the prompt form, so you can dynamically populate the drop down.
Is your data in the public caslib? If so, just enter the following in the autoexec field:
libname MYCAS cas caslib='public';
Then, try your job again and see if the prompt works correctly.
Thanks a lot for your support.
But the dropdown box stays empty. And when I enable the table selector I can manually choose from libraries, but caslibs are not available.
It sounds like you may still be having an issue assigning the caslib to your compute context. Make sure whatever table you want to use to populate your drop-down list is a global table, and then make sure that the libname statement creating a libref to the caslib has been added as an autoexec statement to the appropriate compute context. I worked up an example using the PUBLIC caslib and the SAS Job Execution compute context, so mine looks like this:
Then I created pretty much the same UI as you - I have a table selector that points to public.cars, a read-only column pointing to the Make column, and a drop-down list that will be populated with Make from public.cars:
Then I can add the job to the job content object:
And I'll get the dynamic drop-down list:
thanks a lot, I had defined the wrong context, cas management service compute context instead of sas job execution compute context 🙂
Catch the best of SAS Innovate 2025 — anytime, anywhere. Stream powerful keynotes, real-world demos, and game-changing insights from the world’s leading data and AI minds.
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.