BookmarkSubscribeRSS Feed
USP2405
Obsidian | Level 7

I have SAS legacy code which is migrated to SAS Viya. In the code ,there are some X-commands which does not execute in SAS Viya. How do I run my x-commands in Viya Studio. 

Example - 

x "rm  /data/sas/xplo/abc2405kjh.csv";

11 REPLIES 11
sbxkoenk
SAS Super FREQ

Hello,

 

You probably have NOXCMD as an option.

Check the log after submitting this:

proc options option=xcmd; run;

But for the operating system command 'rm', you can use the SAS FDELETE function instead!

The FDELETE function allows us to delete directories or files directly controlled by SAS.

 

Koen

USP2405
Obsidian | Level 7
Thank you for the solution.

But there are few more commands like rm, rm -f , cp (copying file from one path to another path).

I will try this option. Hope it will work.
sbxkoenk
SAS Super FREQ

Hello,

 

SAS has many of these functions prefixed with 'f' for dealing with external files.

 

  • fdelete
  • fexist
  • fileexist
  • fopen
  • fclose
  • fcopy
  • fappend
  • ...

BR, Koen

USP2405
Obsidian | Level 7
Good to know these commands.

Our files are on unix and we have x commands for that.

Could you please tell me how these SAS function will work for this x command example.
x "rm /data/sas/xplo/abc2405kjh.csv";



Kurt_Bremser
Super User
data _null_;
rc = filename(fref,"/data/sas/xplo/abc2405kjh.csv");
rc = fdelete(fref);
rc = filename(fref);
run;

Also see the documentation of the FDELETE Function. The other file handling functions are found right next to it.

USP2405
Obsidian | Level 7
Also these SAS functions are not supported in a DATA step that runs in CAS. Then we can not run these in SAS VIYA.
LinusH
Tourmaline | Level 20

My understanding is that if you have non-CAS eligible statements/functions, the data step will execute in SPRE (SAS Compute), which is also part of Viya.

Data never sleeps
USP2405
Obsidian | Level 7
What if i need to execute x commands in SAS Viya?
EdoardoRiva
SAS Employee

Have you seen this page in the official documentation?

https://go.documentation.sas.com/doc/en/sasadmincdc/v_045/calcontexts/n1hjn8eobk5pyhn1wg3ja0drdl6h.h...

That's something that a SAS Admin has to do, not an individual user.

Edoardo Riva is a Principal Technical Architect in the Global Enablement and Learning (GEL) Team within SAS R&D's Customer Technology Adoption Division.
Sajid01
Meteorite | Level 14

Hello @USP2405 
The SAS Viya Administrator can enable XCMD in the SAS Environment manager for SAS Studio V.
This link shows step by step how to enable XCMD in environment Manager. The method works.
https://communities.sas.com/t5/SAS-Communities-Library/SAS-Viya-3-5-SAS-Studio-and-SAS-Compute-Serve...

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Discussion stats
  • 11 replies
  • 3099 views
  • 7 likes
  • 6 in conversation