0
votes

I have three different variables in Stata, var1, var2, and var3.

I need to make a summary table of these three variables so that I have the observation number, mean, sd, min, max as the fields in the resulting summary table.

I am using the following code :

  su var1 if restriction == 2 
  su var2 if restriction == 3 
  su var3 if restriction == 4 

Since the summary table is created from variables that are applied with restrictions, I am unable to use :

  su var1 var2 var3 

I would be very grateful if anyone has any ideas on how to modify my code so that instead of three lines of code I can use one line of code to get a single table will all the stats I require, which I can then copy as a table into my Word document.

1
column (spreadsheet) == variable (Stata). Stata != STATA. The if qualifier is not the if command. Edited accordingly.Nick Cox
Two of those points were made in replying to your previous question. stackoverflow.com/questions/38921539/…Nick Cox

1 Answers

1
votes

Nothing reproducible here without example data. Please study https://stackoverflow.com/help/mcve

But I would go

gen var1_2 = var1 if restriction == 2 
gen var2_3 = var2 if restriction == 3 
gen var3_4 = var3 if restriction == 4 
summarize var1_2 var2_3 var3_4