## How can i estimate the differences at different time?

Occasional Contributor
Posts: 12

# How can i estimate the differences at different time?

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
Super Contributor
Posts: 391

## Re: How can i estimate the differences at different time?

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

Occasional Contributor
Posts: 12

## Re: How can i estimate the differences at different time?

Thank you for your help, but can i ask you to give me an example how to do it, step by step?

Super Contributor
Posts: 391

## Re: How can i estimate the differences at different time?

HI!

Can you supply a data step that creates the data?

//Fredrik

Occasional Contributor
Posts: 12

## Re: How can i estimate the differences at different time?

Sorry i don't know what data do you mean. This data, which i paste it in first post is all i have.
Super Contributor
Posts: 391

## Re: How can i estimate the differences at different time?

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

Occasional Contributor
Posts: 12

## Re: How can i estimate the differences at different time?

Oh ok, here it is.

Super Contributor
Posts: 391

## Re: How can i estimate the differences at different time?

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

Occasional Contributor
Posts: 12

## Re: How can i estimate the differences at different time?

It should be, i would like to estimate if there is any difference between two continuos sampling in within a year and type.

Super Contributor
Posts: 391

## Re: How can i estimate the differences at different time?

``````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

Occasional Contributor
Posts: 12

## Re: How can i estimate the differences at different time?

I'm really new to those kind of procedures, so i must fill anything with before i run it?

Occasional Contributor
Posts: 12

## Re: How can i estimate the differences at different time?

I sorted the old data, but now i can't make a new (want) data.

Occasional Contributor
Posts: 12

## Re: How can i estimate the differences at different time?

Ok, i made it, but is it also possible to get if those differences are statistically different?

Super Contributor
Posts: 391

## Re: How can i estimate the differences at different time?

Sorry, but I think that is out of my knowledge

//Fredrik

Occasional Contributor
Posts: 12

## Re: How can i estimate the differences at different time?

Thank you anyway, i learned couple of new things from you anyway I tried with proc mixed and then with lsmeans but i don't think that is correct. It is really hard to work with so small number of samples.
Discussion stats
• 18 replies
• 255 views
• 2 likes
• 4 in conversation