BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
JAE2019
Obsidian | Level 7

Hi Experts!

 

We are trying to check the scope of the table if it's a global or session scope table. I found this article that recommends to use table.exists... but my question is how can I save the result to a macro variable? So far the results are only referred to under proc cas, but i need to use it for other code sections outside of proc cas.

 

This was the code that we were trying:

proc cas;

table.tableexists result=r/ caslibe = caslib, name = table;

run;

 

coming from this post:

 

https://communities.sas.com/t5/SAS-Communities-Library/An-alternative-approach-to-check-the-scope-of...

 

would greatly appreciate any recommendations! thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

You can use the SYMPUTX function to do this, like so:


proc cas;
action table.tableexists result=r/ caslib = "casuser", name = "sometable";
print r;
rc =symputx("castable_exists", r.exists);
print rc;
run;
%put NOTE: &=castable_exists;
quit;

View solution in original post

3 REPLIES 3
BrunoMueller
SAS Super FREQ

You can use the SYMPUTX function to do this, like so:


proc cas;
action table.tableexists result=r/ caslib = "casuser", name = "sometable";
print r;
rc =symputx("castable_exists", r.exists);
print rc;
run;
%put NOTE: &=castable_exists;
quit;
JAE2019
Obsidian | Level 7
Thank you so much Bruno!
This worked! May I check though, what does the rc value mean? So I understand this step "rc =symputx("castable_exists", r.exists);" is the one assigning the value of r.exists to the macro variable &castable_exists. But now rc resolves to a value of 1. What does this represent?
BrunoMueller
SAS Super FREQ

The return values of the CASL SYMPUTX function are not documented. In CASL you can call a function without assigning the return value to a variable. So this code just runs fine.

symputx("castable_exists", r.exists);