<?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 observations longitudinal dataset by id in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513448#M2529</link>
    <description>&lt;P&gt;Yes, I have tried a data step and I have the good result.&amp;nbsp;&lt;SPAN&gt;This is what I have coded that gives me the good answer:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;by id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if first.id then number_obs=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;else number_obs+1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if last.id then output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc freq data=want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;tables&amp;nbsp;number_obs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The product is a table with the number of observations that each "id" has (how many times data has been collected for this person) and in the last line of the&amp;nbsp;accumulated frequencies I do know how many observations I really have for each "id". The inconvenient&amp;nbsp;is that I have to use a data step that creates a wide table.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I was wondering if there is something more&amp;nbsp;straightforward with "proc freq" (something to use with the "have" table).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 15 Nov 2018 17:16:36 GMT</pubDate>
    <dc:creator>MFraga</dc:creator>
    <dc:date>2018-11-15T17:16:36Z</dc:date>
    <item>
      <title>Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513435#M2524</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I would like to use "proc freq" for descriptive analysis. My data is organized longitudinally so I would like to have the number of observations for "var1" by "id". Here an example of my data:&lt;BR /&gt;&lt;BR /&gt;data have;&lt;BR /&gt;input&lt;BR /&gt;&lt;BR /&gt;id time1 event1 weight var1;&lt;BR /&gt;datalines;&lt;BR /&gt;1 0 0 0.89595 0&lt;BR /&gt;1 1 0 0.89595 0&lt;BR /&gt;1 2 0 0.89595 0&lt;BR /&gt;1 3 0 0.89595 0&lt;BR /&gt;1 4 0 0.89595 0&lt;BR /&gt;1 5 0 0.89595 0&lt;BR /&gt;1 6 0 0.89595 0&lt;BR /&gt;1 7 0 0.89595 0&lt;BR /&gt;1 8 0 0.89595 0&lt;BR /&gt;1 9 0 0.89595 0&lt;BR /&gt;1 10 0 0.89595 0&lt;BR /&gt;1 11 0 0.89595 0&lt;BR /&gt;1 12 0 0.89595 0&lt;BR /&gt;1 13 0 0.89595 0&lt;BR /&gt;2 0 0 1.124591 1&lt;BR /&gt;2 1 1 1.124591 1&lt;BR /&gt;2 2 . 1.124591 1&lt;BR /&gt;3 0 0 1.15698 1&lt;BR /&gt;3 1 0 1.15698 1&lt;BR /&gt;3 2 1 1.15698 1&lt;BR /&gt;3 3 . 1.15698 1&lt;BR /&gt;4 0 1 0.987654 2&lt;BR /&gt;4 1 . 0.987654 2&lt;BR /&gt;4 2 . 0.987654 2&lt;BR /&gt;4 3 . 0.987654 2&lt;BR /&gt;4 4 . 0.987654 2&lt;BR /&gt;5 0 0 1.13999 2&lt;BR /&gt;6 0 0 1.0503 0&lt;BR /&gt;6 1 0 1.0503 0&lt;BR /&gt;6 2 0 1.0503 0&lt;BR /&gt;6 3 0 1.0503 0&lt;BR /&gt;6 4 0 1.0503 0&lt;BR /&gt;6 5 1 1.0503 0&lt;BR /&gt;6 6 . 1.0503 0&lt;BR /&gt;6 7 . 1.0503 0&lt;BR /&gt;6 8 . 1.0503 0&lt;BR /&gt;&lt;BR /&gt;;&lt;BR /&gt;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;The table that I want would give me the number of observations for variable "var1". It would be 2 observations for the level "0", and 2 observations for the level and 2 observations for the level "2" of the variable "var1". Any idea ?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 16:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513435#M2524</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-11-15T16:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513438#M2526</link>
      <description>Did you try anything so far?</description>
      <pubDate>Thu, 15 Nov 2018 16:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513438#M2526</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-15T16:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513448#M2529</link>
      <description>&lt;P&gt;Yes, I have tried a data step and I have the good result.&amp;nbsp;&lt;SPAN&gt;This is what I have coded that gives me the good answer:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;by id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if first.id then number_obs=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;else number_obs+1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if last.id then output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc freq data=want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;tables&amp;nbsp;number_obs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The product is a table with the number of observations that each "id" has (how many times data has been collected for this person) and in the last line of the&amp;nbsp;accumulated frequencies I do know how many observations I really have for each "id". The inconvenient&amp;nbsp;is that I have to use a data step that creates a wide table.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I was wondering if there is something more&amp;nbsp;straightforward with "proc freq" (something to use with the "have" table).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:16:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513448#M2529</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-11-15T17:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513460#M2532</link>
      <description>The data step does not create a wide table. It only counts the number of observations by ID. And this doesn't use VAR1 which you indicated in your original question so now I'm really confused as to what you're trying to do here, especially if this is the result you want.</description>
      <pubDate>Thu, 15 Nov 2018 17:19:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513460#M2532</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-15T17:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513465#M2533</link>
      <description>&lt;P&gt;Sorry not to be clear. I will &lt;SPAN class="short_text"&gt;&lt;SPAN class=""&gt;redo the question&lt;/SPAN&gt;&lt;/SPAN&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:21:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513465#M2533</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-11-15T17:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513467#M2534</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236673"&gt;@MFraga&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Yes, I have tried a data step and I have the good result.&amp;nbsp;&lt;SPAN&gt;This is what I have coded that gives me the good answer:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;set have;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;by id;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if first.id then number_obs=1;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;else number_obs+1;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;if last.id then output;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc freq data=want;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;tables&amp;nbsp;number_obs;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The product is a table with the number of observations that each "id" has (how many times data has been collected for this person) and in the last line of the&amp;nbsp;accumulated frequencies I do know how many observations I really have for each "id". The inconvenient&amp;nbsp;is that I have to use a data step that creates a wide table.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;I was wondering if there is something more&amp;nbsp;straightforward with "proc freq" (something to use with the "have" table).&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;It does not help when place a requirement such as "level 0" but do not mention which variable you are using per the example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc freq data=have;
tables id*event1* var1
       id* event1 id*var1 
       event1*var1
      /list;
run;&lt;/PRE&gt;
&lt;P&gt;provides a number of possible counts, there are others. The * operator creates a cross tabulation of the variables. The LIST option says to show the results on a single line&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 17:21:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513467#M2534</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-15T17:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513514#M2542</link>
      <description>&lt;P&gt;Let me start again. I want to know how many observations I have for my categorical variable "var1". But I just want to count "id" once so I can know how many individuas are in my dataset for each category of "var1". What I produce with a data step is good and I have my answer doing this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;set have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;by id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if first.id then number_obs=1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;else number_obs+1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if last.id then output;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc freq data=want;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;tables var1*number_obs;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I was wondering if there is a way to produce an exit without using a data step first. An example of what I want to do:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;proc freq data=have;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;tables var1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;where first.id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I just need to know the number of individuals (how many different "IDs") I have in my dataset for each level of my categorical variable "var1". Is it clear now ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for the help!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 18:45:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513514#M2542</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-11-15T18:45:31Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513518#M2544</link>
      <description>Thanks for the help. It is not the soluction that I am looking for. I think I did not make a clear question at the beginning.</description>
      <pubDate>Thu, 15 Nov 2018 18:52:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513518#M2544</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-11-15T18:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513520#M2545</link>
      <description>proc sql;&lt;BR /&gt;create table want as&lt;BR /&gt;select var1, count(distinct ID) as N_ID&lt;BR /&gt;from have &lt;BR /&gt;group by var1;&lt;BR /&gt;quit;&lt;BR /&gt;&lt;BR /&gt;Use SQL to do this then. See above.</description>
      <pubDate>Thu, 15 Nov 2018 19:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513520#M2545</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-11-15T19:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513522#M2546</link>
      <description>&lt;P&gt;Thanks again!&lt;/P&gt;</description>
      <pubDate>Thu, 15 Nov 2018 19:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513522#M2546</guid>
      <dc:creator>MFraga</dc:creator>
      <dc:date>2018-11-15T19:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Number observations longitudinal dataset by id</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513959#M2616</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/236673"&gt;@MFraga&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks for the help. It is not the soluction that I am looking for. I think I did not make a clear question at the beginning.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;One thing that helps is to take example data such as you provided and show the expected&amp;nbsp;result as another data step program to show expected result if you want a data set as a result. Or show an example of a report table as built from the example data.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even just clarifying whether you want report tables, read by people, or data sets is important.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 16:27:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Number-observations-longitudinal-dataset-by-id/m-p/513959#M2616</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-11-16T16:27:33Z</dc:date>
    </item>
  </channel>
</rss>

