02-05-2018 02:48 AM
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?
Here is the data:
02-05-2018 04:02 AM
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
02-05-2018 04:36 AM
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
02-05-2018 04:45 AM
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....?
02-05-2018 05:01 AM
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?
02-05-2018 05:51 AM