<?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: PROC REPORT noob--need to kind of transpose my data in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-noob-need-to-kind-of-transpose-my-data/m-p/306985#M65708</link>
    <description>&lt;P&gt;Thanks Shmuel!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That solution is not super-appealing, unfortunately. &amp;nbsp;In my real data I've got 87 rows I need to put out. &amp;nbsp;I could actually run my dset through PROC TRANSPOSE I suppose, but I think I may just switch to PROC TABULATE for this. &amp;nbsp;This code does what I want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data = have ;
  class site ;
  var row1-row2 ;
  tables (row1-row2)*sum="", site / misstext = '0';
run ;
&lt;/PRE&gt;
&lt;P&gt;Output from that is:&lt;/P&gt;
&lt;PRE&gt;+-----------------------------------+--------------------------------------+
|                                   |                 site                 |
|                                   +------------+------------+------------+
|                                   |    east    |   north    |   south    |
+-----------------+-----------------+------------+------------+------------+
|No. flu shots    |                 |       23.00|        7.00|        5.00|
+-----------------+-----------------+------------+------------+------------+
|No. broken arms  |                 |       14.00|        1.00|       35.00|
+-----------------+-----------------+------------+------------+------------+&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 24 Oct 2016 23:05:51 GMT</pubDate>
    <dc:creator>RoyPardee</dc:creator>
    <dc:date>2016-10-24T23:05:51Z</dc:date>
    <item>
      <title>PROC REPORT noob--need to kind of transpose my data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-noob-need-to-kind-of-transpose-my-data/m-p/306896#M65688</link>
      <description>&lt;P&gt;Hey All,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've got patient-level data grouped by site, like so:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have ;
  input
    @1    site  $char5.
    @7    mrn   $char6.
    @14   row1  2.0
    @18   row2  2.0
  ;
  label
    row1 = "No. flu shots"
    row2 = "No. broken arms"
  ;
datalines ;
east  roy     2  12
east  bob    21   .
east  mary    .   2
north sara    0   1
north trevor  7   .
south alice   1   0
south bart    1   0
south tim     0  31
south iggy    2   4
south gene    1   0
south don     0   0
run ;&lt;/PRE&gt;
&lt;P&gt;So--data in columns (vars) that I would like to report as rows.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can get pretty much a perfect transpose of the report I want with this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc report data = have ;
  column site row1 row2 ;
  define site / group ;
  define row1 / 'flu shots' ;
  define row2 / 'arms' ;
run ;&lt;/PRE&gt;
&lt;P&gt;That spits out:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  site   flu shots       arms
  east          23         14
  north          7          1
  south          5         35&lt;/PRE&gt;
&lt;P&gt;But what I really want is more like:&lt;/P&gt;
&lt;PRE&gt;                    site
            east     north    south
flu shots     23         7        5
arms          14         1       35&lt;/PRE&gt;
&lt;P&gt;My impulse was to change site from a /group var to an /across var. &amp;nbsp;But when I do that, I get just a single row, with row counts under each listed site, followed by individual columns for my row1 &amp;amp; row2 vars, with sums over all sites.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suspect that REPORT will easily do this for me, I just don't know how to make my wishes intelligible to it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can one of you kind gurus enlighten me?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Roy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 18:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-noob-need-to-kind-of-transpose-my-data/m-p/306896#M65688</guid>
      <dc:creator>RoyPardee</dc:creator>
      <dc:date>2016-10-24T18:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT noob--need to kind of transpose my data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-noob-need-to-kind-of-transpose-my-data/m-p/306925#M65693</link>
      <description>&lt;P&gt;By a middle datastep to &lt;STRONG&gt;prepare&lt;/STRONG&gt; the data HAVE and using &lt;STRONG&gt;proc tabulate&lt;/STRONG&gt; I got the wanted output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have ;&lt;BR /&gt; input&lt;BR /&gt; @1 site $char5.&lt;BR /&gt; @7 mrn $char6.&lt;BR /&gt; @14 row1 2.0&lt;BR /&gt; @18 row2 2.0&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/71462"&gt;@18&lt;/a&gt; row2 2.0&lt;BR /&gt; ;&lt;BR /&gt; label&lt;BR /&gt; row1 = "No. flu shots"&lt;BR /&gt; row2 = "No. broken arms"&lt;BR /&gt; ;&lt;BR /&gt;datalines ;&lt;BR /&gt;east roy 2 12&lt;BR /&gt;east bob 21 .&lt;BR /&gt;east mary . 2&lt;BR /&gt;north sara 0 1&lt;BR /&gt;north trevor 7 .&lt;BR /&gt;south alice 1 0&lt;BR /&gt;south bart 1 0&lt;BR /&gt;south tim 0 31&lt;BR /&gt;south iggy 2 4&lt;BR /&gt;south gene 1 0&lt;BR /&gt;south don 0 0&lt;BR /&gt;run ;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data &lt;STRONG&gt;help&lt;/STRONG&gt;;&lt;BR /&gt; set have;&lt;BR /&gt; length text $15;&lt;BR /&gt; keep site text row;&lt;BR /&gt; text ='flu shots';&lt;BR /&gt; row = row1; output;&lt;BR /&gt; text = 'arms';&lt;BR /&gt; row = row2; output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc tabulate data=&lt;STRONG&gt;help&lt;/STRONG&gt;;&lt;BR /&gt; class site text;&lt;BR /&gt; var row;&lt;BR /&gt; table text=' ',&lt;BR /&gt; site*row*sum=' '*f=5.;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 19:30:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-noob-need-to-kind-of-transpose-my-data/m-p/306925#M65693</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2016-10-24T19:30:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROC REPORT noob--need to kind of transpose my data</title>
      <link>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-noob-need-to-kind-of-transpose-my-data/m-p/306985#M65708</link>
      <description>&lt;P&gt;Thanks Shmuel!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That solution is not super-appealing, unfortunately. &amp;nbsp;In my real data I've got 87 rows I need to put out. &amp;nbsp;I could actually run my dset through PROC TRANSPOSE I suppose, but I think I may just switch to PROC TABULATE for this. &amp;nbsp;This code does what I want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data = have ;
  class site ;
  var row1-row2 ;
  tables (row1-row2)*sum="", site / misstext = '0';
run ;
&lt;/PRE&gt;
&lt;P&gt;Output from that is:&lt;/P&gt;
&lt;PRE&gt;+-----------------------------------+--------------------------------------+
|                                   |                 site                 |
|                                   +------------+------------+------------+
|                                   |    east    |   north    |   south    |
+-----------------+-----------------+------------+------------+------------+
|No. flu shots    |                 |       23.00|        7.00|        5.00|
+-----------------+-----------------+------------+------------+------------+
|No. broken arms  |                 |       14.00|        1.00|       35.00|
+-----------------+-----------------+------------+------------+------------+&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2016 23:05:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/PROC-REPORT-noob-need-to-kind-of-transpose-my-data/m-p/306985#M65708</guid>
      <dc:creator>RoyPardee</dc:creator>
      <dc:date>2016-10-24T23:05:51Z</dc:date>
    </item>
  </channel>
</rss>

