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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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