Programming the statistical procedures from SAS

How can i estimate the differences at different time?

Reply
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:  

DATESAMPLINGYEARTYPEFAT
14.07.201511EKO2,44
14.07.201511KON2,53
12.08.201521EKO3,06
12.08.201521KON2,84
9.09.201531EKO3,19
9.09.201531KON3,14
7.10.101541EKO2,84
7.10.201541KON3,00
4.11.201551EKO3,15
4.11.201551KON3,18
8.06.201612EKO2,70
8.06.201612KON2,86
6.07.201622EKO2,85
6.07.201622KON2,61
1.08.201632EKO2,75
1.08.201632KON2,73
7.09.201642EKO2,92
7.09.201642KON2,90
5.10.201652EKO3,29
5.10.201652KON3,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 Smiley Happy

 

 

//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 Smiley Happy

//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 Smiley Happy

//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 Smiley Happy 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.
Ask a Question
Discussion stats
  • 18 replies
  • 255 views
  • 2 likes
  • 4 in conversation