<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: number of cycles and length of each cycle in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/number-of-cycles-and-length-of-each-cycle/m-p/68766#M19695</link>
    <description>What does your origin dataset look like?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
    <pubDate>Tue, 24 May 2011 09:26:38 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2011-05-24T09:26:38Z</dc:date>
    <item>
      <title>number of cycles and length of each cycle</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/number-of-cycles-and-length-of-each-cycle/m-p/68765#M19694</link>
      <description>How is it possible to determine the number of estrous cycles in dogs when the occurrence of the cycle is given.&lt;BR /&gt;
&lt;BR /&gt;
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. &lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
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.&lt;BR /&gt;
&lt;BR /&gt;
The output has to look like this:&lt;BR /&gt;
animal_id cycle1 cycle2 cycle3&lt;BR /&gt;
101            5         3          2&lt;BR /&gt;
102            2         3          1&lt;BR /&gt;
103            3         1          2</description>
      <pubDate>Mon, 23 May 2011 22:58:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/number-of-cycles-and-length-of-each-cycle/m-p/68765#M19694</guid>
      <dc:creator>saslover</dc:creator>
      <dc:date>2011-05-23T22:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: number of cycles and length of each cycle</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/number-of-cycles-and-length-of-each-cycle/m-p/68766#M19695</link>
      <description>What does your origin dataset look like?&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 24 May 2011 09:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/number-of-cycles-and-length-of-each-cycle/m-p/68766#M19695</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-24T09:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: number of cycles and length of each cycle</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/number-of-cycles-and-length-of-each-cycle/m-p/68767#M19696</link>
      <description>It has many variables. But the variable of interest has observations that look like this&lt;BR /&gt;
&lt;BR /&gt;
Est&lt;BR /&gt;
Di&lt;BR /&gt;
Met&lt;BR /&gt;
Sp&lt;BR /&gt;
Est&lt;BR /&gt;
&lt;BR /&gt;
and so on</description>
      <pubDate>Tue, 24 May 2011 09:38:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/number-of-cycles-and-length-of-each-cycle/m-p/68767#M19696</guid>
      <dc:creator>saslover</dc:creator>
      <dc:date>2011-05-24T09:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: number of cycles and length of each cycle</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/number-of-cycles-and-length-of-each-cycle/m-p/68768#M19697</link>
      <description>Whether is The following code what you want.&lt;BR /&gt;
I have to leave now,Sorry. If you have some problems ,I will be here tomorrow this time.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data temp;&lt;BR /&gt;
 input id $ x $;&lt;BR /&gt;
cards;&lt;BR /&gt;
101 Est&lt;BR /&gt;
101 Di&lt;BR /&gt;
101 Met&lt;BR /&gt;
101 Sp&lt;BR /&gt;
101 Est&lt;BR /&gt;
101 Met&lt;BR /&gt;
101 Sp&lt;BR /&gt;
101 Met&lt;BR /&gt;
101 Est&lt;BR /&gt;
102 Est&lt;BR /&gt;
102 Met&lt;BR /&gt;
102 Sp&lt;BR /&gt;
102 Est&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
data have;&lt;BR /&gt;
 set temp;&lt;BR /&gt;
 if x='Est' then do;&lt;BR /&gt;
                   cycle+1;&lt;BR /&gt;
                   duration=0;&lt;BR /&gt;
                  end;&lt;BR /&gt;
 if id ne lag(id) then cycle=0;&lt;BR /&gt;
 duration+1;&lt;BR /&gt;
run;&lt;BR /&gt;
data _want(keep=id lag_dur cycle_no);&lt;BR /&gt;
 set have;&lt;BR /&gt;
 lag_dur=lag(duration);&lt;BR /&gt;
 if id ne lag(id) then call missing(lag_dur);&lt;BR /&gt;
 if x='Est' then do;&lt;BR /&gt;
                   cycle_no=cats('cycle',cycle);&lt;BR /&gt;
                   output;&lt;BR /&gt;
                 end;&lt;BR /&gt;
run;&lt;BR /&gt;
proc transpose data=_want out=want;&lt;BR /&gt;
 by id;&lt;BR /&gt;
 id cycle_no;&lt;BR /&gt;
 var lag_dur;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
Ksharp</description>
      <pubDate>Tue, 24 May 2011 10:45:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/number-of-cycles-and-length-of-each-cycle/m-p/68768#M19697</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2011-05-24T10:45:22Z</dc:date>
    </item>
  </channel>
</rss>

