Is there any ways to run Stata from within SAS? I have Stata installed on my PC.
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.
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?
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.
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.
Sorry- I am still not clear about it. An example would have been great.
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.
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.
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.