How do I execute this SAS command in Stata?

How do I execute this SAS command in Stata?

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 PROCStata Command(s)UCLA Web PagesStata ManualBooks
PROC XYZ ;
  WHERE ___;
xyzcommand if (___)Using “if” for subsetting
with Stata Commands
[U] 11.1.3 if expishr – 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] appendishr – 9.5
PROC COMPARE;cf.[R] anova 
PROC CONTENTS;describe.[D] describe 
PROC CORRcorrelate
pwcorr
– Overview of statistical
tests in Stata
– Annotated
output for the correlation command
[R] correlate 
PROC CORR ALPHA;alpha.[R] alpha 
PROC DELETEerase.[D] erase 
PROC FACTORfactorAnnotated 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;
tabulateOverview of statistical
tests in Stata
[R] tabulate onewayishr – 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);
logisticData
Analysis Example: Logistic Regression
[R] logistic 
PROC LOGISTIC;
 (multinomial);
mlogitData
Analysis Example: Multinomial Logistic Regression
[R] mlogit 
PROC LOGISTIC;
 (ordinal);
ologitData
Analysis Example: Ordinal Logistic Regression
[R] ologit 
PROC MEANS;summarize– Descriptive information and statistics
– Annotated output
for the summarize command
[R] summarizeishr 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] collapseishr – 9.6
PROC PRINT;list.[D] list 
PROC PRINTTO;log.[R] log 
PROC PROBIT;probitData
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] sortishr – 9.4
PROC STDIZE;egen Creating and Recoding Variables[D] egenishr 8.1
PROC TTESTttestOverview of statistical
tests in Stata
 ishr – 10.4
PROC UNIVARIATEsummarize , detail [R]
summarize
 
      
      

SAS DATA STEP Statements and the closest equivalent Stata command

SAS DATA STEP
Statement
Stata Command(s)UCLA Web PagesStata ManualBooks
* ;
/* */
(comments)
*
/* */
//
.[P] commentsishr 4.8
x = 2;
(assignment)
generate
replace
egen
Creating and Recoding Variables[D] generate
[D] replace
[D] egen
ishr 8.1
ARRAYforeachWorking across
variables using foreach
[P] foreachishr – 17.4
DATA in.new;saveUsing and saving Stata
data files
[D] saveishr – 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 expishr – 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] dropishr – 9.2
%INCLUDEdo ___.[R] do 
FORMATformat.[D] formatishr – 5.2
KEEP
DROP
keep
drop
Subsetting variables and observations[D] drop 
LABELlabel variableLabeling data,
variables and values
[D] labelishr – 7.1
MERGEmergeCombining Stata data
files
[D] mergeishr – 9.5
PUTdisplay.[P] display 
SET data1;useUsing and saving Stata
data files
[D] useishr – 6.1
SET data1data2data3;
concatenating data files
append

Combining data
 

[D] appendishr – 9.5
RENAMErename.[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.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top