BookmarkSubscribeRSS Feed
ramkal21
Obsidian | Level 7

Hi All,

Could you please let me know if i can call COBOL programs from SAS? any example for doing that?

 

Thanks,

Ramanujam

7 REPLIES 7
Reeza
Super User
Yes and No.
You can call an external cobol program to get processed assuming you have all the libraries and dependencies needed, using an X command. This does need x command enabled.

In terms of running a cobol program and then using that data within SAS, likely not without some additional processing to read in a data.

More details about your use case would be helpful.
SASKiwi
PROC Star

To start with SAS and COBOL need to be installed on the same computer. Also if COBOL can be run from an OS command line, then the SAS X command as mentioned by @Reeza can execute it. 

Kurt_Bremser
Super User

In most cases, COBOL is a compiled language, which means that COBOL code is first fed to the COBOL compiler, after which you get an executable file (e.g. a .exe under Windows) which can be run from the commandline.

SAS provides several methods to run such external commands (X statement, SYSTEM function, CALL SYSTEM routine, INFILE or FILE statement with the PIPE device), which need the XCMD system option set at SAS startup.

Even if you had a COBOL interpreter at hand, you would still need to run it as an external command to which you feed the COBOL code.

There is no built-in SAS tool for compiling or interpreting COBOL.

ramkal21
Obsidian | Level 7

Thank you @Reeza @SASKiwi @Kurt_Bremser  for your inputs. Could you please clarify how to verify XCMD is setup during SAS startup?

Also, could you please point me to any documentation with examples of using the external commands such as 'X' from @Kurt_Bremser 's post?

 

I am trying to replace one of FOCUS utility programs with SAS and we have below FOCUS call to COBOL program like below. Please note that am trying to run both the SAS and COBOL in z/OS Mainframe environment.

INCLUDE <<COBOL Executable>>

 

Please let me know if you need more details. 

 

Thanks.

SASKiwi
PROC Star

How would you run a COBOL program directly if you didn't use Focus? You can confirm if the SAS X command is enabled or not by running this:

proc options option = xcmd;
run;

If the result is XCMD, then it is enabled. If it is NOXCMD it is disabled.

ramkal21
Obsidian | Level 7

Thanks @SASKiwi  for the update. I received the response as 'XCMD', so it is enabled in our environment.

I will try to use the XCMD and will let you know if i am successful at it.

Patrick
Opal | Level 21

This old paper might be of interest to you. There is more out there if you search a bit.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 7 replies
  • 2844 views
  • 3 likes
  • 5 in conversation