BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hpatel3
Obsidian | Level 7

Hello,

I'm having a bit of trouble setting up my SAS equation here and would value some input:

 

The prompt 

  1. calculate the P values for continuous variables comparing first values at first echo date and last echo date for:

                       Max wall thickness in Echo 1 vs  Max wall thickness in Echo 2

                        LVEDd  in Echo 1 vs  LVEDd   in Echo 2

                        EF  in Echo 1 vs EF in Echo 2

                        LA in Echo 1 vs LA  in Echo 2

 

 

 

 Example data looks something like this:

 

ex.JPG

 

How do I set up the values for comparison  Value 1 Max Wall thickness vs Value 2 Wall thickness AND  Value 1 LVEDd vs Value 2 LVEDd AND  EF 1 value vs. EF 2 value AND  LA 1 value vs. LA 2 value?

 

My guess was this: 

 

 

libname Hetal "\\tuftsmc\home\hpatel3\SAS Class Datasets";

run;

 

proc import out= Hetal. ES_ Pvals datafile= "\\tuftsmc\home\hpatel3\SAS Datasets\surv_unemp.csv" dbms=csv replace;

getnames=yes; datarow=2;

run;

 

proc freq data=Hetal.es_pvals order=formatted;
Tables MWT1*MWT2 / chisq;
Title "Comparison of Key variables at First Echo vs Last Echo in ES patients";
run

 

 

 

 What I keep getting is this: 

 

 

 huh- pval..JPG

 

 

What I'm assuming I want is a p value, ie the comparison between MWT1 and MWT2 and their association .0001 (or something). 

 

1 ACCEPTED SOLUTION

Accepted Solutions
sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

I would consider using the TTEST procedure with the PAIRED statement. See this example from the documentation.

 

View solution in original post

7 REPLIES 7
aebabinec
Calcite | Level 5

Hi there, 

 

I suggest setting up a indicator variable to denote whether the measure comes from the first time or second time.

 

And then in your proc freq, add a by statement with the new variable. This should separate out your data and compare the variable across time points.

 

 

hpatel3
Obsidian | Level 7

Hi, @aebabinec. So instead of proc freq, I tried using a one-sample T-Test just now since I'm comparing two points of the same variable. Does that work? Is my code correct? should I be worried that some of my means are negative?(code and results attached)

 

pval final.JPG

And my Pvalues (and results )are thus:

 

P val results.JPG

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

I would consider using the TTEST procedure with the PAIRED statement. See this example from the documentation.

 

hpatel3
Obsidian | Level 7
That's much clear! PAIRED made it just a bit cleaner/tighter numbers. Thank you so much!
tamhane
Obsidian | Level 7

Examining the same variable at 2 different points is a paired design.

If continuous variable, then you can do T1-T2 (or T2-T1) to get the differences and then run PROC UNIVARIATE to get the p-value for Signed rank test (Null hypothesis is that the difference is equal to zero).

If the variable is categorical then it would be a 2x2 paired table and can use McNemar's test to get the p-value which compares the marginal frequencies. The odds ratio here would be labelled as conditional odds ratio that will be calculated using the discordant cells (Null hypothesis is OR=1).

Hope this helps.

 

Ashutosh

 

hpatel3
Obsidian | Level 7

 

@sld@tamhane: It seems I don't understand this as well as I thought

 

 

The example given by you (SLD) showed this:

 

ex paired.PNG

 

and the code I have is this:

 

pair code.PNG

 My data has 4 variables I am looking at at date of first echo and date of last echo. Your example has two comparison times SBP Before * SBP after. However I have 4 variables being measure at Date of first Echo and Date of Last echo:

 

:MWT (mm) at time of first echo
MWT (mm) at time of last echo

EF (%) at time of first echo

EF (%) at time of last echo

 

I'm not sure what the "paired" statement code would be like for this many variables. Can you elucidate a bit? Between what variables would my asterisk go between? MWT*_____ LVEDD*_____  EF*______  LA*_____ 

 

or would it look like something different?

etc.

 

sld
Rhodochrosite | Level 12 sld
Rhodochrosite | Level 12

In your code, you are computing the difference (time 1 - time 2), and then using that difference in proc TTEST. As you have suspected, this is not correct.

 

As noted by @tamhane, you can either (1) compute the difference and then test whether the difference is zero using proc UNIVARIATE using differences as the response variable, or (2) you can use pairs of values in proc TTEST with the PAIRED statement.

 

Each variable--MWT, LVEDD, EF and LA--will be analyzed separately.

 

For example, using TTEST with PAIRED using pairs of values

 

proc ttest data=hetal.es_pv;
   paired MWT1*MWT2;
run; 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 2565 views
  • 0 likes
  • 4 in conversation