BookmarkSubscribeRSS Feed
saslover
Calcite | Level 5
How is it possible to determine the number of estrous cycles in dogs when the occurrence of the cycle is given.

For instance, when the determinants of the cycle is given by DI,PR,ES,ME,S,P where DI=diestrus,PR=Proestrus,ES=estrus,ME=metestrus,S=sperm,P=plug.

The occurrence of estrus is only that matters and the cycle is given by EST DI DI DI MET EST -- here the length of the cycle is 5 until the occurrence of next estrus.

A cycle is calculated from one estrus to another estrus. The length of the cycle is the period until next estrus occurs which is 5 in the above case.

How do I write a code to calculate this in Statistics. The endpoint is to calculate the number of cycles and length of each cycle.

The output has to look like this:
animal_id cycle1 cycle2 cycle3
101 5 3 2
102 2 3 1
103 3 1 2
3 REPLIES 3
Ksharp
Super User
What does your origin dataset look like?


Ksharp
saslover
Calcite | Level 5
It has many variables. But the variable of interest has observations that look like this

Est
Di
Met
Sp
Est

and so on
Ksharp
Super User
Whether is The following code what you want.
I have to leave now,Sorry. If you have some problems ,I will be here tomorrow this time.


[pre]


data temp;
input id $ x $;
cards;
101 Est
101 Di
101 Met
101 Sp
101 Est
101 Met
101 Sp
101 Met
101 Est
102 Est
102 Met
102 Sp
102 Est
;
run;
data have;
set temp;
if x='Est' then do;
cycle+1;
duration=0;
end;
if id ne lag(id) then cycle=0;
duration+1;
run;
data _want(keep=id lag_dur cycle_no);
set have;
lag_dur=lag(duration);
if id ne lag(id) then call missing(lag_dur);
if x='Est' then do;
cycle_no=cats('cycle',cycle);
output;
end;
run;
proc transpose data=_want out=want;
by id;
id cycle_no;
var lag_dur;
run;
[/pre]


Ksharp

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1076 views
  • 0 likes
  • 2 in conversation