BookmarkSubscribeRSS Feed
_maldini_
Barite | Level 11

I am designing a prospective study w/ one group of participants. Continuous outcome variables will be measured at 3 points in time (i.e., baseline, timepoint_1, timepoint_2). The statistical analysis will likely be a paired t-test, two-way ANOVA, repeated-measures ANOVA, or something in that ballpark. There is also a possibility this will be collapsed into a simple pre/post study. TBD. Feedback on the analysis is also welcome.

 

Among other things, I'm assuming I will need a mean score - as a separate variable - for each time point  (i.e., baseline_mean, timepoint_1_meanscore, timepoint_2_meanscore).

 

Am I correct?

If so, what is the best way to accomplish this?

 

A small sample dataset attached. I'm a beginner-intermediate SAS programmer. 

 

Thank you. 

 

 

9 REPLIES 9
ballardw
Super User

@_maldini_ wrote:

I am designing a prospective study w/ one group of participants. Continuous outcome variables will be measured at 3 points in time (i.e., baseline, timepoint_1, timepoint_2). The statistical analysis will likely be a paired t-test, two-way ANOVA, repeated-measures ANOVA, or something in that ballpark. There is also a possibility this will be collapsed into a simple pre/post study. TBD. Feedback on the analysis is also welcome.

 

Among other things, I'm assuming I will need a mean score - as a separate variable - for each time point  (i.e., baseline_mean, timepoint_1_meanscore, timepoint_2_meanscore).

 

Am I correct?

If so, what is the best way to accomplish this?

 

A small sample dataset attached. I'm a beginner-intermediate SAS programmer. 

 

Thank you. 

 

 


Mean score of what?

The only numeric values that a mean would make any sense in your data is possibly the VAS or possibly age. I don't think timestamp would make much sense and everything else is character.

 

_maldini_
Barite | Level 11
I'm sorry. I attached the wrong dataset. I have uploaded the correct dataset.

<Mean score of what?>
Mean score of VAS, pain score, interference score and/or adherence score
ballardw
Super User

Something like perhaps?

Proc means data=yourdataset;
   class redcap_event_name;
   var Vas <other variable names>;
run;

You haven't stated whether you need a data set or not, if so what should that data set look like?

_maldini_
Barite | Level 11

The syntax you provided will give me the mean across the class variable, which is helpful. But, I'm trying to determine how to calculate a mean for each time point that can be output as its own variable. For example, baseline_mean, timepoint_1_meanscore, timepoint_2_meanscore, which would be added to the existing dataset as new variables.

 

If I conduct a paired t-test, for example, and I need the mean difference across 2 timepoints (e.g., timepoint_2_meanscore minus baseline_mean), I need to use the following syntax: 

PROC TTEST DATA=dataset-name ALPHA=.05; 
PAIRED V1*V2; 
RUN;

I'm assuming V1 and V2 above are means that I need to calculate from each timepoint. Am I wrong about that?

Thanks for your help.

ballardw
Super User

@_maldini_ wrote:

The syntax you provided will give me the mean across the class variable, which is helpful. But, I'm trying to determine how to calculate a mean for each time point that can be output as its own variable. For example, baseline_mean, timepoint_1_meanscore, timepoint_2_meanscore, which would be added to the existing dataset as new variables.

 

If I conduct a paired t-test, for example, and I need the mean difference across 2 timepoints (e.g., timepoint_2_meanscore minus baseline_mean), I need to use the following syntax: 

PROC TTEST DATA=dataset-name ALPHA=.05; 
PAIRED V1*V2; 
RUN;

I'm assuming V1 and V2 above are means that I need to calculate from each timepoint. Am I wrong about that?

Thanks for your help.


You are at a point where you really need to provide an example of what you think the data set would look like.

Proc means data=yourdataset nway noprint;
   class redcap_event_name;
   var Vas <other variable names>;
   output out=work.summary mean= /autoname;
run;

For example will create a mean for each level of the even_name of the variables and have the word "mean" as a suffix.

But I'm not sure how you expect to run much of a t-test on these summary values.

 

I think that you may want to transpose the data so that you have one each variable and use "timepoint" as the variable.

data example;
   infile datalines dlm=',' dsd;
   input record_id redcap_event_name :$15. age vas pain interference  adherence ;
datalines;
1,Baseline,44,7,7,6,
1,Follow-up #1,,6,5,5,3
1,Follow-up #2,,4,3,3,4
2,Baseline,55,7,5,5,
2,Follow-up #1,,4,2,4,3
2,Follow-up #2,,3,1,3,5
3,Baseline,37,5,4,5,
3,Follow-up #1,,4,3,3,6
3,Follow-up #2,,0,1,2,4
4,Baseline,56,3,4,3,
4,Follow-up #1,,3,4,2,3
4,Follow-up #2,,3,2,1,6
5,Baseline,64,7,5,6,
5,Follow-up #1,,5,4,4,3
5,Follow-up #2,,3,2,2,2
;

proc transpose data=example
   out=trans1;
   by record_id;
   id redcap_event_name;
   var vas pain interference  adherence ;
run;

proc sort data=trans1;
  by _name_;
run;

proc ttest data=trans1;
  by _name_;
  paired baseline*Follow_up__1;
run;

This uses the power of "by group" processing to the same thing based on the value of a variable in the data set, in this case the type of measure. The sort and transpose gets the values for type of measurement and the names of the "timepoints" as the variable to analyze. 

With the reshaped data we test the type of measure by each value of the original variable name. So with one set of code we test all the baseline * follow_up__1 pairs.

 

Warning: If your variable names don't look like mine you may want to play with the system option validvarname=V7 to avoid having to write variable names like "follow up #1"n. Or make the text for the follow up values more acceptable as variable names such as "FollowUp1" and "FollowUp2". 

The data step turns you posted data into a data step, you shouldn't need to do that. In the future, please open a text box on the forum by clicking on the </> and paste the csv text into it.

_maldini_
Barite | Level 11
Thank you. I'm working thru your response now...I don't follow: "The data step turns you posted data into a data step..."? Are you saying that in the future I should paste the contents of the csv file by selecting the </> option?
ballardw
Super User

@_maldini_ wrote:
Thank you. I'm working thru your response now...I don't follow: "The data step turns you posted data into a data step..."? Are you saying that in the future I should paste the contents of the csv file by selecting the </> option?

Data is best shared as data step code. That way it is pretty easy to tell everything about the data, variable type, formats and such. We sometimes spend 15 or more messages trying to get someone to clearly describe their data only to find out what they thought was number is actually a text value. So of course you can't do XXX with characters.

 

The </> is a better choice for posting any text like CSV. The Forum software or your browser (haven't been able to determine exactly which culprit) often attempts to display CSV with spreadsheet software. That conversion that goes on the background can change values. So plain text goes into a text box. That way we see exactly what you paste. The main windows will reformat text and may result in something that doesn't represent your actual file.

_maldini_
Barite | Level 11

<You are at a point where you really need to provide an example of what you think the data set would look like.>

 

I realize this is very important, but I don't actually know what the data set should look like. I have never done an analysis like this before.

 

The transposed data set looks promising, but w/ your syntax, how do you tell SAS what level of the _NAME_ variable to use for the t-test? In other words, if I just wanted to run the t-test for the vas variable...

 

Also, I may do a repeated-measures ANOVA, which is also new to me. How would I specify the variable in that scenario? With a Class statement?

_maldini_
Barite | Level 11

I guess I would feel more competent w/ the data if it looked like this: 

record_id	Baseline_adherence	FollowUp1_adherence	FollowUp2_adherence	Baseline_interference	FollowUp1_interference	FollowUp2_interference	Baseline_pain	FollowUp1_pain	FollowUp2_pain	Baseline_vas	FollowUp1_vas	FollowUp2_vas
1		3	4	6	5	3	7	5	3	7	6	4
2		3	5	5	4	3	5	2	1	7	4	3
3		6	4	5	3	2	4	3	1	5	4	0
4		3	6	3	2	1	4	4	2	3	3	3
5		3	2	6	4	2	5	4	2	7	5	3

Also uploaded since it looks weird in the <\> box.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 9 replies
  • 1837 views
  • 4 likes
  • 2 in conversation