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

Dear scientists, I have a question about ttest.  

 

Description of my dataset: there are four colums. Colum GDM is the group 0 or 1. Y_m is the group mean. How can I carry out t-tests comparing GDM 0 to GDM 1 of each of the six outcomes which are SFA MUFA PUFA6 DHA PUFA3 N3_N6?

I proc my code but no result. Need help 🙂

 

Here is the data

 

data fattyACID;
length ACID $5.;
input ACID $ GDM Y_m Y_sd;
if GDM=0 then Y_n=84; else Y_n=24;
datalines;
SFA 0 43.5 3.4
SFA 1 44.7 2.8
MUFA 0 24.5 2.2
MUFA 1 25.6 2.2
PUFA6 0 25.8 2.5
PUFA6 1 24.7 2.5
DHA 0 3.5 1.1
DHA 1 2.9 0.8
PUFA3 0 4.4 2.1
PUFA3 1 3.5 0.9
N3_N6 0 0.17 0.07
N3_N6 1 0.14 0.04
;
run;

Here is my proc, I think I follow the step which in SAS support , but I don't get result.(https://support.sas.com/documentation/cdl/en/statug/63033/HTML/default/viewer.htm#statug_ttest_sect0...)

 

proc sort;
   by acid gdm;
run;
proc print data=fattyacid;
run;

proc means data=fattyACID noprint;
class acid;
var y_m;
 by gdm;
 output out=newfattyACID;
run;
proc print data=newfattyACID;
run;

proc ttest data=newfattyACID;
by acid;
class gdm;
var y_m;
run; 
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@Jackwangliang wrote:

Thank you dear balladw!

Then how about this data, I add y_n for the gdm group individual count, can SAS proc ttest. Or I still have to do it manually?

Thanks a lot!

 

data fattyACID;
length ACID $5.;
input ACID $ GDM Y_m Y_sd y_n;

 SFA 0 43.50 3.40 84 
 SFA 1 44.70 2.80 24 
 MUFA 0 24.50 2.20 84 
 MUFA 1 25.60 2.20 24 
 PUFA6 0 25.80 2.50 84 
 PUFA6 1 24.70 2.50 24 
 DHA 0 3.50 1.10 84 
 DHA 1 2.90 0.80 24 
 PUFA3 0 4.40 2.10 84 
 PUFA3 1 3.50 0.90 24 
 N3_N6 0 0.17 0.07 84 
 N3_N6 1 0.14 0.04 24 

;
run;

 

In the data prior to the Fattyacid data were all of the measurements exactly the same for each measurement? If so then you could use the above data with Freq y_n; But I doubt that was the case. Proc TTEST requires information to calculate the Standard Deviation within each group compared. That means some variability in the data . If you go look at your original Newfattyacid, assuming you managed to create it as you have syntax errors (fattyacid is sorted incorrectly) you will see that you have STD missing for EVERY acid GDM combination. If you can find a value for STD for each then you could use the data but Proc Means can't create one and you don't have any variability in the data attempting to use the FREQ option will either fail completely or yield very missleading results.

 

Also, if you do find the value for STD you will need to make the data set look like the output of proc means not the structure you currently have.

View solution in original post

4 REPLIES 4
ballardw
Super User

Since your data only includes one value for acid per gdm there isn't much to do here. The Proc TTEST expects to see one record per observation or have a variable that indicates the frequency count in the raw data for individual measurements.

 

If you have summary data, such as a mean, you would really need to have the n and standard deviation to manually to a ttest.

If you summarized another set to get your Fattyacid data use that one for proc ttest.

Jackwangliang
Calcite | Level 5

Thank you dear balladw!

Then how about this data, I add y_n for the gdm group individual count, can SAS proc ttest. Or I still have to do it manually?

Thanks a lot!

 

data fattyACID;
length ACID $5.;
input ACID $ GDM Y_m Y_sd y_n;

 SFA 0 43.50 3.40 84 
 SFA 1 44.70 2.80 24 
 MUFA 0 24.50 2.20 84 
 MUFA 1 25.60 2.20 24 
 PUFA6 0 25.80 2.50 84 
 PUFA6 1 24.70 2.50 24 
 DHA 0 3.50 1.10 84 
 DHA 1 2.90 0.80 24 
 PUFA3 0 4.40 2.10 84 
 PUFA3 1 3.50 0.90 24 
 N3_N6 0 0.17 0.07 84 
 N3_N6 1 0.14 0.04 24 

;
run;
ballardw
Super User

@Jackwangliang wrote:

Thank you dear balladw!

Then how about this data, I add y_n for the gdm group individual count, can SAS proc ttest. Or I still have to do it manually?

Thanks a lot!

 

data fattyACID;
length ACID $5.;
input ACID $ GDM Y_m Y_sd y_n;

 SFA 0 43.50 3.40 84 
 SFA 1 44.70 2.80 24 
 MUFA 0 24.50 2.20 84 
 MUFA 1 25.60 2.20 24 
 PUFA6 0 25.80 2.50 84 
 PUFA6 1 24.70 2.50 24 
 DHA 0 3.50 1.10 84 
 DHA 1 2.90 0.80 24 
 PUFA3 0 4.40 2.10 84 
 PUFA3 1 3.50 0.90 24 
 N3_N6 0 0.17 0.07 84 
 N3_N6 1 0.14 0.04 24 

;
run;

 

In the data prior to the Fattyacid data were all of the measurements exactly the same for each measurement? If so then you could use the above data with Freq y_n; But I doubt that was the case. Proc TTEST requires information to calculate the Standard Deviation within each group compared. That means some variability in the data . If you go look at your original Newfattyacid, assuming you managed to create it as you have syntax errors (fattyacid is sorted incorrectly) you will see that you have STD missing for EVERY acid GDM combination. If you can find a value for STD for each then you could use the data but Proc Means can't create one and you don't have any variability in the data attempting to use the FREQ option will either fail completely or yield very missleading results.

 

Also, if you do find the value for STD you will need to make the data set look like the output of proc means not the structure you currently have.

Jackwangliang
Calcite | Level 5

Thank you! This is the point.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 4 replies
  • 1239 views
  • 0 likes
  • 2 in conversation