## StatLab Frequently Asked Questions (FAQ)

We keep track of the questions we hear frequently and post them here on our web site. If you don't find the question and answer you are look for, try our help pages, and if you still don't find it, contact us!

- How can I automatically log off my machine after running a Stata do-file?
- How can I get help for a specific Matlab question that no one can answer?
- I just cannot remember how some MatLab functions work, how can I get the correct syntax?
- How do I change my working directory within Matlab?
- How do I get started with Matlab?
- Question: Why can’t I download this data set from ICPSR into SPSS or SAS so that I can convert it to STATA?
- How do I send files to someone else if they are too large for email?
- How do I put the STATA tables I see in the results window into Word?
- How do I put the STATA tables I see in the results window into Excel?
- How do I access the ESPY file on Capital Executions in the US?
- What if my network drives do not appear when I log on?
- How do I add a new library to R?
- How do I open an SPSS file in SAS??
- Why is SPSS not saving my work at the end of a session?
- In Stata, how do you sum variables across columns into a new variable?
- Why is there no printer?
- How do I fix my zip file?
- How do I zip and unzip folders?
- How do I install ado files for personal use?
- How do I create a .zip file from a bunch of files?
- How do I set Memory in Stata?
- How do I convert documents into PDF files?
- How do I print from the StatLab?
- What happens if I don t log off the Statlab computers?
- Where do I find social and economic data to use in a class, an assignment, or a research project?

In Stata, how do you sum variables across columns into a new variable?

In Stata, the egen command combined with rsum allows the user to sum data across columns into a new variable. For example, with two variables, var1 and var2, we can create a third, var3, which is the sum of the two, with the command: egen var3 = rsum(var1 var2) We can then create the variable var4 as the sum of var1, var2, and var3, using the command, egen var4 = rsum(var1 var2 var3) or equivalently, egen var4 = rsum(var1-var3) An alternative way to sum across columns is just to add, as in, gen var4 = var1 + var2 + var3 There is one difference between the two methods - "egen rsum" sums across columns even if there are missing values. "gen sum" sums across columns only if all of the values are non-missing. Note: there are many other row operator commands in Stata that work similarly, such as, rmax, rmean, rmiss, etc.