The process of executing a SAS command in Stata involves first accessing the command window in Stata and then entering the desired SAS command, followed by pressing the “Enter” key. This will allow the user to run the SAS command and produce the desired output in Stata. It is important to ensure that the SAS command is compatible with Stata and that any necessary data or files are properly imported into Stata before executing the command. Additionally, it may be helpful to refer to Stata’s documentation or seek assistance from experienced users to ensure proper execution of the SAS command in Stata.
How do I do this SAS Command in Stata? | Stata FAQ
Say that you use SAS but wish to know how to do a particular command in
Stata. For example, you want to make a new variable and know you can use the
assignment statement (e.g. x = 1;) to
create a new variable in SAS, but what is the equivalent (or similar) command
in Stata (by the way, there are actually three similar Stata commands,
generate, replace, and egen). The table below shows you five
columns of information
This table is by no means complete, and it not intended to
be a complete and exhaustive reference. Instead, it is intended to be a short,
simple, sweet and handy reference for SAS users who are making the transition
to Stata. We also highly recommend
A Sample Stata Session
(via the Stata web site) which gives you a quick overview of using Stata as well
as seeing the [GS] Getting Started manual that accompanied your purchase of
Stata.
The first table shows SAS PROCs and the closest equivalent Stata command. The
subsequent table shows statements from DATA Steps.
SAS PROCs to Stata commands
| SAS PROC | Stata Command(s) | UCLA Web Pages | Stata Manual | Books |
| PROC XYZ ; WHERE ___; | xyzcommand if (___) | Using “if” for subsetting with Stata Commands | [U] 11.1.3 if exp | ishr – 4.4 |
| PROC XYZ; BY abc; | by abc: xyzcommand | . | [D] by [U] 11 Language syntax | ishr – 4.7 |
| PROC XYZ ; WEIGHT wt; | xyzcommand [fweight=wt] | What types of weights do SAS, Stata and SAS support? | [U] l11.1.6 weight | ishr – 4.5 |
| PROC APPEND; | append | Combining data | [D] append | ishr – 9.5 |
| PROC COMPARE; | cf | . | [R] anova | |
| PROC CONTENTS; | describe | . | [D] describe | |
| PROC CORR | correlate pwcorr |
– Overview of statistical tests in Stata – Annotated output for the correlation command | [R] correlate | |
| PROC CORR ALPHA; | alpha | . | [R] alpha | |
| PROC DELETE | erase | . | [D] erase | |
| PROC FACTOR | factor | Annotated output for the factor command | [MV] factor | |
| PROC FORMAT; FORMAT var fmt; | label define label values | Labeling data, variables and values | [D] | ishr – 7.1 |
| PROC FREQ; TABLES a; | tabulate | Overview of statistical tests in Stata | [R] tabulate oneway | ishr – 10.3 |
| PROC FREQ; TABLES a*b; | tabulate tab2 | Overview of statistical tests in Stata | [R] tabuluate twoway | ishr 10.3 |
| PROC GLM; | anova | . | [R] anova | |
| PROC LOGISTIC; (binary); | logistic | Data Analysis Example: Logistic Regression | [R] logistic | |
| PROC LOGISTIC; (multinomial); | mlogit | Data Analysis Example: Multinomial Logistic Regression | [R] mlogit | |
| PROC LOGISTIC; (ordinal); | ologit | Data Analysis Example: Ordinal Logistic Regression | [R] ologit | |
| PROC MEANS; | summarize | – Descriptive information and statistics – Annotated output for the summarize command | [R] summarize | ishr 10.1 |
| PROC MEANS; CLASS a; VAR b; | tabulate a, summarize(b) | Overview of statistical tests in Stata | [R] summarize [R] tabulate, summarize() | ishr – 10.4 |
| PROC MIXED; | xtmixed | . | [XT] xtmixed | |
| PROC MEANS; OUTPUT; PROC SUMMARY; OUTPUT | collapse | Collapsing data across observations | [D] collapse | ishr – 9.6 |
| PROC PRINT; | list | . | [D] list | |
| PROC PRINTTO; | log | . | [R] log | |
| PROC PROBIT; | probit | Data Analysis Example: Probit Regression | [R] probit | |
| PROC REG; | regress | – Regression with Stata – Annotated output for the regress command | [R] regress | |
| PROC REG ; OUTPUT OUT= | predict | [R] predict | ||
| PROC ROBUSTREG; | rreg | Chapter 4 – Beyond OLS | [R] rreg | |
| PROC SORT; | sort | . | [D] sort | ishr – 9.4 |
| PROC STDIZE; | egen | Creating and Recoding Variables | [D] egen | ishr 8.1 |
| PROC TTEST | ttest | Overview of statistical tests in Stata | ishr – 10.4 | |
| PROC UNIVARIATE | summarize , detail | [R] summarize | ||
SAS DATA STEP Statements and the closest equivalent Stata command
| SAS DATA STEP Statement | Stata Command(s) | UCLA Web Pages | Stata Manual | Books |
| * ; /* */ (comments) | * /* */ // | . | [P] comments | ishr 4.8 |
| x = 2; (assignment) | generate replace egen | Creating and Recoding Variables | [D] generate [D] replace [D] egen | ishr 8.1 |
| ARRAY | foreach | Working across variables using foreach | [P] foreach | ishr – 17.4 |
| DATA in.new; | save | Using and saving Stata data files | [D] save | ishr – 6.1 |
| DO i = 1 to 10; | forvalues | . | [P] forvalues | |
| IF (cond) THEN x = ___; | generate x = __ if (cond) | Using “if” for subsetting with Stata Commands | [U] 11.1.3 if exp | ishr – 8.1 |
| INFILE INPUT | infile infix insheet | Inputting raw data files into Stata | [D] infile (free format) [D] insheet [D] infix (fixed format) | ishr 6.3 |
| IF (___) THEN OUTPUT; IF (___) THEN DELETE; | keep if ___ drop if ___ | Subsetting variables and observations | [D] drop | ishr – 9.2 |
| %INCLUDE | do ___ | . | [R] do | |
| FORMAT | format | . | [D] format | ishr – 5.2 |
| KEEP DROP | keep drop | Subsetting variables and observations | [D] drop | |
| LABEL | label variable | Labeling data, variables and values | [D] label | ishr – 7.1 |
| MERGE | merge | Combining Stata data files | [D] merge | ishr – 9.5 |
| PUT | display | . | [P] display | |
| SET data1; | use | Using and saving Stata data files | [D] use | ishr – 6.1 |
| SET data1data2data3; concatenating data files | append | Combining data | [D] append | ishr – 9.5 |
| RENAME | rename | . | [D] rename |
Legend
Cite this article
stats writer (2024). How do I execute this SAS command in Stata?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-do-i-execute-this-sas-command-in-stata/
stats writer. "How do I execute this SAS command in Stata?." PSYCHOLOGICAL SCALES, 1 Jul. 2024, https://scales.arabpsychology.com/stats/how-do-i-execute-this-sas-command-in-stata/.
stats writer. "How do I execute this SAS command in Stata?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-do-i-execute-this-sas-command-in-stata/.
stats writer (2024) 'How do I execute this SAS command in Stata?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-do-i-execute-this-sas-command-in-stata/.
[1] stats writer, "How do I execute this SAS command in Stata?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, July, 2024.
stats writer. How do I execute this SAS command in Stata?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.
