1. Assigning an .ADO directory on the Stat Apps Terminal Server
2. Reshaping data from long to wide format or vise versa
3. Quitting long output and returning control to the keyboard
4. Getting skewness and kurtosis p-values
 


Assigning an .ADO directory on the Stat Apps Terminal Server.

Question:

Help! I’m trying to download an .ADO file in Stata (using ssc), but the Windows Terminal Server won’t let me – it seems write-protected.

Answer:

The Windows Terminal Server in indeed write protected, and as such we’ll need to change the .ADO directory.  In the Stata command window type

Sysdir

This will list the current assignments of Stata’s default directories.  Notice the PLUS directory is assigned as “C:\ado\plus”.  This C: drive is actually on the WTS, as Stata is running on the server.  This is what we’ll need to change.

To start, create a new folder in you’re My Documents directory on the WTS.  Double-click the My Documents folder on your desktop on the WTS.  Create a new folder here called Stata.  Within your new Stata folder create an ADO folder.

Now, in Stata type the following:

sysdir set PLUS "U:\My Documents\Stata\ADO"

This will re-assign the PLUS directory to the U: drive – your personal drive on the WTS tied to your UT EID.  Now, you are free to download the ado file of your choice.  For example:

ssc install newprogramname

Typing the above will load everything associated with the .ADO file on the ssc server (http://www.repec.org).


Reshaping data from long to wide format and vice versa

Question:

I've got data in long format, where each row is a single measurement and subjects have multiple rows.  But I need to run a repeated measures ANOVA - is there an easy way to convert it into wide format, where each row contains all measurements for each subject?  Or vice versa?

Answer:

Stata's "reshape" command makes it easy to transform your data from either long to wide format or from wide to long.  As an example, consider the data below presented in both formats (the data itself is identical, but organized in a different way):

Long Format













Wide Format

Id

Factor

Measure













Id

Factor1

Factor1

1

1

82













1

82

87

1

2

87













2

90

91

2

1

90













3

78

87

2

2

91













...







3

1

78






















3

2

87






















...    









   

Below is the syntax if your data is in long format and you want it in wide format:

reshape wide Measure, i(Id) j(Factor)

where Measure is the variable that is repeated, Id is the subject ID, and Factor is the within-subject factor. The resulting dataset will have a single subject for each line, with the Factor variable name repeated in several variables named Factor1, Factor2, etc. for however many measurements you have in your study.

To go from wide format to long format, you must have your within-subject variables named as described above.  Then, the syntax is the same as before except you replace "wide" with "long":

reshape long Measure, i(Id) j(Factor)

The resulting dataset will have a single new variable named Factor which contains the measurements for each factor level in multiple rows for each subject.


Quitting long output and returning control to the keyboard

Question:

I accidently told Stata to output something that was hundreds of rows long and I don't want to sit hear and hit spacebar hundreds of times to get to the end of it.  Is there a way to return control to the keyboard?

Answer:

Yes, to return control back to the keyboard and quit the output, just hit Q.


Getting skewness and kurtosis p-values

Question:

I'm testing to see if a variable violates the assumption of normality and am able to get the skewness and kurtosis statistics from the sum, detail command.  But how do I get the relative p-values for those measures?

Answer:

You can use the sktest command, followed by the variable or variables that you want tested.  The output will look like the following.  If the probability of skewness or kurtosis is less than 0.05, then you reject the null hypothesis that these statistics do not differ from zero, meaning that the assumption of normality might be violated.  In the example below, the Price variable has a significant skew, but a non-significant kurtosis:

sktest