Hi guys!
I came across a problem with a small sample, where we did measure the amount of fat in goat's milk during 2 year experiment (YEAR), where we took samples continuosly 5 times (SAMPLING) each year from 2 different groups (TYPE) of goats. And now we need to know if there was some kind of difference between each sampling in each year?
Can somebody help me with that?
Thank you,
Here is the data:
DATE | SAMPLING | YEAR | TYPE | FAT |
14.07.2015 | 1 | 1 | EKO | 2,44 |
14.07.2015 | 1 | 1 | KON | 2,53 |
12.08.2015 | 2 | 1 | EKO | 3,06 |
12.08.2015 | 2 | 1 | KON | 2,84 |
9.09.2015 | 3 | 1 | EKO | 3,19 |
9.09.2015 | 3 | 1 | KON | 3,14 |
7.10.1015 | 4 | 1 | EKO | 2,84 |
7.10.2015 | 4 | 1 | KON | 3,00 |
4.11.2015 | 5 | 1 | EKO | 3,15 |
4.11.2015 | 5 | 1 | KON | 3,18 |
8.06.2016 | 1 | 2 | EKO | 2,70 |
8.06.2016 | 1 | 2 | KON | 2,86 |
6.07.2016 | 2 | 2 | EKO | 2,85 |
6.07.2016 | 2 | 2 | KON | 2,61 |
1.08.2016 | 3 | 2 | EKO | 2,75 |
1.08.2016 | 3 | 2 | KON | 2,73 |
7.09.2016 | 4 | 2 | EKO | 2,92 |
7.09.2016 | 4 | 2 | KON | 2,90 |
5.10.2016 | 5 | 2 | EKO | 3,29 |
5.10.2016 | 5 | 2 | KON | 3,61 |
Do a sort by type and date, the use the lag(FAT) function to compare values between observations.
You might also need the first. function to reset figures. You need to use set by; for this to function 🙂
//Fredrik
Thank you for your help, but can i ask you to give me an example how to do it, step by step?
HI!
Can you supply a data step that creates the data?
//Fredrik
Hi!
I ment the data that you posted, but I don't want to spend a lot of time just trying to create the test data set.
If you can supply that, it makes it a lot easier for me to help you 🙂
//Fredrik
Oh ok, here it is.
Thanks!
Is it the difference between samplings, i.e: between 1 and 2, 2 and 3, 3 and 4 or between sampling and year, i.e: sampling 1 year 1 and sampling 1 year2, sampling 2 year 1 and sampling 2 year2....?
//Fredrik
It should be, i would like to estimate if there is any difference between two continuos sampling in within a year and type.
proc sort data=fat;
by type year date;
run;
data want;
set fat;
by type year date;
prev_fat=lag(fat);
diff_fat=dif(fat);
if first.year then do;
prev_fat = .;
diff_fat = .;
end;
run;
Will this work?
//Fredrik
I'm really new to those kind of procedures, so i must fill anything with before i run it?
I sorted the old data, but now i can't make a new (want) data.
Ok, i made it, but is it also possible to get if those differences are statistically different?
Sorry, but I think that is out of my knowledge 🙂
//Fredrik
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!
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.