BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
xiaoys0725
Fluorite | Level 6

Hello, 

 
I have an issue with runCode Action and save Action. 
 
1st one is the runCode Action. I submitted the following code, and cart is a cas table in a caslib called "MYCASLIB3". 
 
proc cas;
         datastep.runCode submit /                          
         code =  
         "data cart; 
         length id 8 name $100 units 8 price 8;
         id=1000; 
         name='iphone5s';
         units=1;
         price=4300;
         run;";                             
   run;
   quit;
 
I should have only 1 row in the output, while I got 8 rows. No idea why it is 8 rows. 
 
I also tried other codes like output statement, or "data cart;set work.cart;run;" every time I got 8 rows*the row I am supposed to have. 
 
2st thing is when I used the save action. My save action is like this("proc cas" omitted):
 
table.save /
    table="cart"
    caslib="MYCASLIB3"
    name="cart.sashdat"
    replace=true;
    run;
 
I found I cannot save the cart table into my cart.sashdat because I load the table from cart.sashdat and then fetched the table again and I still got the previous records. I also tried table={name="cart",caslib="MYCASLIB3"} and it still does not work. 
1 ACCEPTED SOLUTION

Accepted Solutions
BrunoMueller
SAS Super FREQ

Have a look at the dataStep.runCode action, if you are not reading from any table, the code gets execute on each node, this is why you get the 8 output rows.

 

You can specify the SINGLE="NOINPUT" to run the code only one node

 

datastep.runCode submit  status=rc /
  
   single="noinput" code=sasCode
   ;
 print rc;

See also DATA Step Processing Modes for more information.

View solution in original post

4 REPLIES 4
BrunoMueller
SAS Super FREQ

Have a look at the dataStep.runCode action, if you are not reading from any table, the code gets execute on each node, this is why you get the 8 output rows.

 

You can specify the SINGLE="NOINPUT" to run the code only one node

 

datastep.runCode submit  status=rc /
  
   single="noinput" code=sasCode
   ;
 print rc;

See also DATA Step Processing Modes for more information.

xiaoys0725
Fluorite | Level 6

Thank you, it works now. May I ask if you know about CAS REST API? I got another issue about the api when I ran fetch action

BrunoMueller
SAS Super FREQ

Please start a new thread with the question on the REST API.

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2780 views
  • 2 likes
  • 2 in conversation