BookmarkSubscribeRSS Feed
BayzidurRahman
Obsidian | Level 7

Is there any ways to run Stata from within SAS? I have Stata installed on my PC.

6 REPLIES 6
SASKiwi
Opal | Level 21

Where is your SAS installed? If you have SAS installed on your PC you can start Stata from SAS using the X command. Not sure why you would want to do that rather than just starting Stata manually.

BayzidurRahman
Obsidian | Level 7

SAS is also installed on the same PC.
I am doing a long data processing job. Most of the tasks will be performed in SAS. Stata is very efficient to perform an intermediate task. Thus, I want to use Stata from within SAS to do that specific job and then import the generated data into SAS to do the remaining task. Can you please give an example of the x command?

SASKiwi
Opal | Level 21
x 'dir c:\*.*';

The X command allows you to run any command that works from a Windows command line. Within the quotes you just need to substitute the Stata command you wish to run. Test it first from a Windows command line or command window and once it works you can paste the command into your SAS program.

Kurt_Bremser
Super User

You need to first make up the stata sub-task so that it can be executed from one commandline command.

Then you can run that sub-task from within SAS like this.

data _null_;
infile "your_stata_commandline_here 2>&1" pipe;
input;
put _infile_;
run;

All messages from the stata execution (information, output and diagnostic) will end up in the SAS log. The X statement will not provide this information.

bayzid
Obsidian | Level 7

Sorry- I am still not clear about it. An example would have been great.

Kurt_Bremser
Super User

You must first find out how to run your stata task in batch.

Keep in mind that this here is the SAS communities, you won't find that much stata expertise here. I've never worked with stata.

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 6 replies
  • 213 views
  • 0 likes
  • 4 in conversation