Issues with describing data in long form

Issues with describing data in long form

by Katherine Dang -
Number of replies: 3

Hello,

After spending an excruciatingly long time getting my dataset cleaned, I am having issues now trying to get the descriptive tables to appropriately show the subjects and variables in the columns and rows, respectively, with the scores listed due to the repeated measures in my table. Being that my data is in the long form, all of the scores are shown instead of the actual variables (i.e. survey names) in the columns or rows with the subjects when I try to tabulate the data. Would transforming the data into the wide form be more appropriate in this case?

To elaborate on my end goal, I am trying to make a table showing the average subscores from the surveys (listed in rows) for each subject listed in the columns. I had tried tabulating by subject_id survey variable to no avail. I had also tried bysort commands (i.e. bysrot subject_id: sum survey variable)  and other variations of these with little luck.

Thanks

 

 

 

 

 

In reply to Katherine Dang

Re: Issues with describing data in long form

by Wayne Enanoria -

In general, one puts individuals (or whatever sampling unit) in the rows and the scores as columns rather than having subjects in the columns. You can then do different operations on the score variables as we have done in class. If you are summarizing data in long form, it is sometimes better to use the wide format for data summaries, but it depends on what you are trying to achieve. I am not sure this helps you at all -- feel free to send more details of the structure of your data and what you are trying to do.

In reply to Katherine Dang

Re: Issues with describing data in long form

by Bardia -

Depending on your goal; there are several ways to describe your data when your dataset is in long format. For example, you usually report the mean score for a particular test at baseline (mean of baseline score of all patients) or any other particular visit or time point (e.g. mean score of all patients at the last visit). This is very easy to do in Stata (while your dataset is in long format):

sum Testscore if visit==1

 

or

 

sum age if month==0

or

tab male if visit==1

 

On the other hand, if you want to report the mean score of all time points (all visits) of a particular test for every patient (e.g. you want to report the mean blood pressure of 10 visits for each patient; so you are actually reporting (for example) 40 means if you have 40 patients; this would be the right syntax (although I don't know how informative this reporting would be):

 

bysort PatientID: sum BloodPressure

 

As I mentioned above; the more common practice would be to report the mean score of a test at a particular visit or time point.

 

In reply to Bardia

Re: Issues with describing data in long form

by Katherine Dang -

Thank you so much for the advice. The bysort actually worked once I inputted all of the variables at once in the sum portion of the command. I am meaning to show the average scores for each subject for now since not all of the subjects have multiple equal amount of time points. So this worked well so far. However, another issue that arose now is that all of the variables I renamed via the label var old var new var are now not displaying on the tables after bysort. Not sure why this occurred and would this lead to me being deducted points if the labels are not displayed on the tables in the log file?

 

Thanks!