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
PROC Star

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
PROC Star
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.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 6 replies
  • 370 views
  • 0 likes
  • 4 in conversation