<?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: counting over time in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74038#M21441</link>
    <description>Hi:&lt;BR /&gt;
  I wondered whether you might want a report... something like one of these:&lt;BR /&gt;
[pre]&lt;BR /&gt;
+------------------------------------------------------------------------+&lt;BR /&gt;
|Patient Visit Status|                status                |            |&lt;BR /&gt;
|                    +--------------------------------------+            |&lt;BR /&gt;
|                    |    Appt    |            |            |            |&lt;BR /&gt;
|                    |  Attended  |Miss Holiday|Miss Illness| All Types  |&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Patient             |            |            |            |            |&lt;BR /&gt;
+--------------------+            |            |            |            |&lt;BR /&gt;
|Alice               |        2.00|        2.00|           0|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Bob                 |        1.00|        1.00|        2.00|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Carla               |        3.00|           0|        1.00|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Dan                 |        3.00|        1.00|           0|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|All Patients        |        9.00|        4.00|        3.00|       16.00|&lt;BR /&gt;
+------------------------------------------------------------------------+&lt;BR /&gt;
                         &lt;BR /&gt;
or&lt;BR /&gt;
            &lt;BR /&gt;
+------------------------------------------------------------------------+&lt;BR /&gt;
|Daily Visit Status  |                status                |            |&lt;BR /&gt;
|                    +--------------------------------------+            |&lt;BR /&gt;
|                    |    Appt    |            |            |            |&lt;BR /&gt;
|                    |  Attended  |Miss Holiday|Miss Illness|All Patients|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Day                 |            |            |            |            |&lt;BR /&gt;
+--------------------+            |            |            |            |&lt;BR /&gt;
|typeday1            |        1.00|        1.00|        2.00|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|typeday2            |        3.00|        1.00|           0|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|typeday3            |        2.00|        1.00|        1.00|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|typeday4            |        3.00|        1.00|           0|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|All Days            |        9.00|        4.00|        3.00|       16.00|&lt;BR /&gt;
+------------------------------------------------------------------------+&lt;BR /&gt;
   &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
These two reports are examples of what you can do with PROC TABULATE. If you keep the data "wide", so that all the info for one patient is on one obs, then your choice to count is to use array processing. If you use PROC TRANSPOSE to turn the wide data into long and skinny data, then other procedures open up to you for reporting. &lt;BR /&gt;
 &lt;BR /&gt;
In addition, you can create user-defined formats, like the ones below, that would allow you to display a meaningful label, such as "Appt Attended" or "Miss Holiday" instead of codes 2 or 3. Or, formats could even be used to associate a name with an id. &lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
   value typvis&lt;BR /&gt;
     2='Appt Attended'&lt;BR /&gt;
     3='Miss Holiday'&lt;BR /&gt;
     4='Miss Illness';&lt;BR /&gt;
                   &lt;BR /&gt;
   value PtID &lt;BR /&gt;
     1 = 'Alice'&lt;BR /&gt;
     2 = 'Bob'&lt;BR /&gt;
     3 = 'Carla'&lt;BR /&gt;
     4 = 'Dan';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
What kind of report did you envision? Or were you interested in a data set? &lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
    <pubDate>Sun, 15 Feb 2009 07:21:55 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2009-02-15T07:21:55Z</dc:date>
    <item>
      <title>counting over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74036#M21439</link>
      <description>Hi, I'm a new SAS user, and I could use some help. I would like to be able to look at frequency (or counts) over time. My data set has 80 days, and for each day, there is a value representing appointment attendance (e.g., attended, missed due to illness, missed due to holiday, etc.). My data looks like this:&lt;BR /&gt;
&lt;BR /&gt;
ID typeday1 typeday2 typeday3 typeday4 .......up to typeday80&lt;BR /&gt;
1      3            2            3              2&lt;BR /&gt;
2      4            2            4              3&lt;BR /&gt;
&lt;BR /&gt;
What I'd like to be able to do is:&lt;BR /&gt;
a) find out, looking across all 80 days, how many appointments each person attended (e.g., 2s), how many did they miss due to holiday (e.g., 3), etc.&lt;BR /&gt;
and&lt;BR /&gt;
b) somehow looking across every person and every day overall, how many appointments were missed for each reason. &lt;BR /&gt;
&lt;BR /&gt;
Any suggestions for how to accomplish this would be great. &lt;BR /&gt;
&lt;BR /&gt;
Thanks!</description>
      <pubDate>Sat, 14 Feb 2009 13:58:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74036#M21439</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-14T13:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: counting over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74037#M21440</link>
      <description>I would tranpose tranpose the data to &lt;BR /&gt;
[pre]&lt;BR /&gt;
id     day       visitType&lt;BR /&gt;
1-n   1-80       1-4&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
But here is code to work with the wide data.&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data typeday(drop=typeDay:);&lt;BR /&gt;
   array typeday[80];&lt;BR /&gt;
   infile cards missover;&lt;BR /&gt;
   input id:$3. typeday&lt;LI&gt;;&lt;BR /&gt;
   array tCount[4];&lt;BR /&gt;
   call missing(of tCount&lt;/LI&gt;&lt;LI&gt;);&lt;BR /&gt;
   do _n_ = 1 to dim(typeday) while(not missing(typeday[_n_]));&lt;BR /&gt;
      tCount[typeday[_n_]] + 1;&lt;BR /&gt;
      end;&lt;BR /&gt;
   TotalMissed = sum(of tcount2-tcount4); *2,3,4 are missed codes?;&lt;BR /&gt;
   cards;&lt;BR /&gt;
1 3 2 3 2&lt;BR /&gt;
2 4 2 4 3&lt;BR /&gt;
;;;;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;/LI&gt;</description>
      <pubDate>Sat, 14 Feb 2009 16:19:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74037#M21440</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2009-02-14T16:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: counting over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74038#M21441</link>
      <description>Hi:&lt;BR /&gt;
  I wondered whether you might want a report... something like one of these:&lt;BR /&gt;
[pre]&lt;BR /&gt;
+------------------------------------------------------------------------+&lt;BR /&gt;
|Patient Visit Status|                status                |            |&lt;BR /&gt;
|                    +--------------------------------------+            |&lt;BR /&gt;
|                    |    Appt    |            |            |            |&lt;BR /&gt;
|                    |  Attended  |Miss Holiday|Miss Illness| All Types  |&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Patient             |            |            |            |            |&lt;BR /&gt;
+--------------------+            |            |            |            |&lt;BR /&gt;
|Alice               |        2.00|        2.00|           0|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Bob                 |        1.00|        1.00|        2.00|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Carla               |        3.00|           0|        1.00|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Dan                 |        3.00|        1.00|           0|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|All Patients        |        9.00|        4.00|        3.00|       16.00|&lt;BR /&gt;
+------------------------------------------------------------------------+&lt;BR /&gt;
                         &lt;BR /&gt;
or&lt;BR /&gt;
            &lt;BR /&gt;
+------------------------------------------------------------------------+&lt;BR /&gt;
|Daily Visit Status  |                status                |            |&lt;BR /&gt;
|                    +--------------------------------------+            |&lt;BR /&gt;
|                    |    Appt    |            |            |            |&lt;BR /&gt;
|                    |  Attended  |Miss Holiday|Miss Illness|All Patients|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|Day                 |            |            |            |            |&lt;BR /&gt;
+--------------------+            |            |            |            |&lt;BR /&gt;
|typeday1            |        1.00|        1.00|        2.00|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|typeday2            |        3.00|        1.00|           0|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|typeday3            |        2.00|        1.00|        1.00|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|typeday4            |        3.00|        1.00|           0|        4.00|&lt;BR /&gt;
+--------------------+------------+------------+------------+------------+&lt;BR /&gt;
|All Days            |        9.00|        4.00|        3.00|       16.00|&lt;BR /&gt;
+------------------------------------------------------------------------+&lt;BR /&gt;
   &lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
These two reports are examples of what you can do with PROC TABULATE. If you keep the data "wide", so that all the info for one patient is on one obs, then your choice to count is to use array processing. If you use PROC TRANSPOSE to turn the wide data into long and skinny data, then other procedures open up to you for reporting. &lt;BR /&gt;
 &lt;BR /&gt;
In addition, you can create user-defined formats, like the ones below, that would allow you to display a meaningful label, such as "Appt Attended" or "Miss Holiday" instead of codes 2 or 3. Or, formats could even be used to associate a name with an id. &lt;BR /&gt;
[pre]&lt;BR /&gt;
proc format;&lt;BR /&gt;
   value typvis&lt;BR /&gt;
     2='Appt Attended'&lt;BR /&gt;
     3='Miss Holiday'&lt;BR /&gt;
     4='Miss Illness';&lt;BR /&gt;
                   &lt;BR /&gt;
   value PtID &lt;BR /&gt;
     1 = 'Alice'&lt;BR /&gt;
     2 = 'Bob'&lt;BR /&gt;
     3 = 'Carla'&lt;BR /&gt;
     4 = 'Dan';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
 &lt;BR /&gt;
What kind of report did you envision? Or were you interested in a data set? &lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Sun, 15 Feb 2009 07:21:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74038#M21441</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-02-15T07:21:55Z</dc:date>
    </item>
    <item>
      <title>Re: counting over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74039#M21442</link>
      <description>Thank you both so much for your help!&lt;BR /&gt;
&lt;BR /&gt;
Cynthia, I think for now I would like to keep the data wide and use an array like you suggested to count across appointment days. Because then I could use the "count" generated in other analyses. Do you have any suggestions of what such an array might look like? &lt;BR /&gt;
&lt;BR /&gt;
There are 10 appointment days, and on each day you could have any one of 5 outcomes (e.g., attended, missed because doctor cancelled, missed because sick, missed because holiday, missed for personal reasons). &lt;BR /&gt;
&lt;BR /&gt;
What I'd eventually like to be able to say is that across all participants and all appointment days, X% of appointments were attended, X% were missed because the doctor cancelled, etc.&lt;BR /&gt;
&lt;BR /&gt;
Thanks for your help, and hope that made sense!</description>
      <pubDate>Sun, 15 Feb 2009 14:05:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74039#M21442</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-15T14:05:30Z</dc:date>
    </item>
    <item>
      <title>Re: counting over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74040#M21443</link>
      <description>Hi:&lt;BR /&gt;
  Well, there was an example of an array in data_null_'s post. For a beginner, sometimes working with Arrays can be challenging. This paper is a good introduction to Array processing:&lt;BR /&gt;
&lt;A href="http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf" target="_blank"&gt;http://support.sas.com/rnd/papers/sgf07/arrays1780.pdf&lt;/A&gt; &lt;BR /&gt;
&lt;BR /&gt;
There is an alternative, however, to using arrays. &lt;BR /&gt;
&lt;BR /&gt;
You can keep the data in whatever form you want -- you can keep it long and wide for storage and reference and data entry purposes. But then you can create temporary datasets to do all the countring.&lt;BR /&gt;
             &lt;BR /&gt;
  SAS has some perfectly wonderful procedures that do counts and percents --and-- if the data is in the right form, will give you ALL the information you want, either in report form or in dataset form.&lt;BR /&gt;
                  &lt;BR /&gt;
Without knowing how you need to use the counts in other analysis, it's hard to make a recommendation about whether arrays are best or whether looking at PROC TRANSPOSE and PROC FREQ are best. Generally, I recommend starting with TRANSPOSE and FREQ or TRANSPOSE and TABULATE for beginners -- because it is easier, sometimes to deal with a self-contained procedure that only does 1 thing than to jump into DATA step processing, where the syntax and the process can sometimes be challenging.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Sun, 15 Feb 2009 17:43:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74040#M21443</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2009-02-15T17:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: counting over time</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74041#M21444</link>
      <description>Thanks so much for your help! I'll try both your and data_null_'s suggestions when I get back to work on Tuesday. I really appreciate it!</description>
      <pubDate>Sun, 15 Feb 2009 18:54:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/counting-over-time/m-p/74041#M21444</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2009-02-15T18:54:29Z</dc:date>
    </item>
  </channel>
</rss>

