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

- SAS commands, listed in alphabetical order
- The equivalent (or similar) Stata command(s).
- Links to UCLA web pages that illustrate the use of the Stata command
- Cross references to the Stata manual for learning more about the command (which is also hot linked to the online help for the command)
- Cross references to books that illustrate more about the command.

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] label |
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 STEPStatement |
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 data1 data2 data3;concatenating data files |
append | Combining data | [D] append | ishr – 9.5 |

RENAME | rename | . | [D] rename |

Legend

*PROC XYZ*stands for any arbitary SAS procedure.*xyzcommand*stands for any arbitrary Stata command- UCLA Web Pages
- "." – no specific page exists. Try visiting the site and using the "search" command to pages that might tangentially refer to the command.

- Stata Manual Names
- [D] Data
- [R] Reference manual
- [U] Users Guide
- [MV] Multivariate Statistics
- [XT] Cross sectional time series

- Book References
- ishr – Introduction to Stata for Health Researchers by Svend Juul