<?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: Reshape in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790426#M32482</link>
    <description>Thanks. I have modified the question after your response. Could you help, how can I create the modified output table.</description>
    <pubDate>Sun, 16 Jan 2022 19:33:51 GMT</pubDate>
    <dc:creator>Barkat</dc:creator>
    <dc:date>2022-01-16T19:33:51Z</dc:date>
    <item>
      <title>Reshape: cross tabulate</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790079#M32445</link>
      <description>&lt;P&gt;I have the following dataset. I am struggling to create a table shown below.&lt;/P&gt;
&lt;P&gt;[Edited the previous question. The changes are in the output table. I added last two rows in the output table. Row A&amp;amp;E is sum of the values in rows A and E. Similarly Row D&amp;amp;E is the sum of the values in rows D and E.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;infile datalines ;&lt;BR /&gt;input&lt;/P&gt;
&lt;P&gt;ID &lt;BR /&gt;Park $&lt;BR /&gt;Month $ ;&lt;BR /&gt;datalines;&lt;BR /&gt;001 A Jan&lt;BR /&gt;002 A Feb&lt;BR /&gt;003 B Mar&lt;BR /&gt;004 C Apr&lt;BR /&gt;005 B Jan&lt;BR /&gt;006 D May&lt;BR /&gt;007 E Jun&lt;BR /&gt;008 A Feb&lt;BR /&gt;009 C Dec&lt;BR /&gt;010 A Nov&lt;BR /&gt;011 D Sep&lt;BR /&gt;012 C Aug&lt;BR /&gt;013 B Oct&lt;BR /&gt;014 B Jul&lt;BR /&gt;015 E Sep&lt;BR /&gt;016 C Nov&lt;BR /&gt;017 D Jul&lt;BR /&gt;018 E Oct&lt;BR /&gt;019 E Mar&lt;BR /&gt;020 C Apr&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 624pt;" border="0" width="832" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 12.5pt;"&gt;
&lt;TD width="64" height="17" style="height: 12.5pt; width: 48pt;"&gt;Park&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Jan&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Feb&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Mar&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Apr&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;May&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Jun&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Jul&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Aug&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Sep&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Oct&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Nov&lt;/TD&gt;
&lt;TD width="64" style="width: 48pt;"&gt;Dec&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.5pt;"&gt;
&lt;TD height="17" style="height: 12.5pt;"&gt;A&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.5pt;"&gt;
&lt;TD height="17" style="height: 12.5pt;"&gt;B&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.5pt;"&gt;
&lt;TD height="17" style="height: 12.5pt;"&gt;C&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;2&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.5pt;"&gt;
&lt;TD height="17" style="height: 12.5pt;"&gt;D&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 12.5pt;"&gt;
&lt;TD height="17" style="height: 12.5pt;"&gt;E&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD align="right"&gt;1&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;A&amp;amp;E&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;2&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;D&amp;amp;E&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;1&lt;/TD&gt;
&lt;TD&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 14 Jan 2022 21:51:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790079#M32445</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2022-01-14T21:51:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790082#M32448</link>
      <description>&lt;P&gt;Basic report:&lt;/P&gt;
&lt;PRE&gt; 
Proc report data=have;
   columns park Month;
   define park/group;
   define month/ across " " order=data;
run;&lt;/PRE&gt;
&lt;P&gt;If you don't want the default . to appear where missing then place before the procedure.&lt;/P&gt;
&lt;PRE&gt;options missing=' ';&lt;/PRE&gt;
&lt;P&gt;and then reset the default missing behavior with: options missing='.'; after.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you need a data set then say so.&lt;/P&gt;
&lt;P&gt;Also, you may find using actual date values in the long run more flexible than character values like "Jan" and "Feb". For one thing you may have a hard time getting things in the correct order because default behavior in many places will place "Apr" first. With an actual date there are several formats such as Monname3. that will display just the month abbreviated name. Plus with a data a change of format could create calendar quarter or year count/totals without changing the data at all.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790082#M32448</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-01-13T23:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790083#M32449</link>
      <description>&lt;P&gt;the less intuitive one &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select park, 
sum(case month when "Jan" then 1 else 0 end) as Jan, 
sum(case month when "Feb" then 1 else 0 end) as Feb,
sum(case month when "Mar" then 1 else 0 end) as Mar,
sum(case month when "Apr" then 1 else 0 end) as Apr,
sum(case month when "May" then 1 else 0 end) as May,
sum(case month when "Jun" then 1 else 0 end) as Jun,
sum(case month when "Jul" then 1 else 0 end) as Jul,
sum(case month when "Aug" then 1 else 0 end) as Aug,
sum(case month when "Sep" then 1 else 0 end) as Sep,
sum(case month when "Oct" then 1 else 0 end) as Oct,
sum(case month when "Nov" then 1 else 0 end) as Nov,
sum(case month when "Dec" then 1 else 0 end) as Dec

from have
group by park;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:51:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790083#M32449</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-01-13T23:51:38Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790084#M32450</link>
      <description>&lt;P&gt;an alternative approach&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
set have;
dummy=1;
run;

proc transpose data=have1 out=want;
by park notsorted;
var dummy;
id month;
run;

proc summary data=want nway;
class park;
var _numeric_;
output out=want1(drop=_:) sum= / autolabel;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:59:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790084#M32450</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-01-13T23:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790090#M32452</link>
      <description>&lt;P&gt;and the IML version of it&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
use have;
read all var {'park'};
read all var {'month'};
close;

u1=unique(park) ;
u2=unique(month);
order={5, 4, 8, 1, 9, 7, 6, 2, 12, 11, 10, 3};
u2=u2[order]`;

res=j(ncol(u1)*ncol(u2),1,.);

do i=1 to ncol(u1);
do j=1 to ncol(u2);
res[j+(i-1)*ncol(u2),1]=t(park=u1[i])*(month=u2[j]);
end;
end;

res1=shape(res, ncol(u1));

print  res1 [rowname=u1 colname=u2];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ok1.png" style="width: 728px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/67390iE2C8E041E2C1220D/image-size/large?v=v2&amp;amp;px=999" role="button" title="ok1.png" alt="ok1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 00:37:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790090#M32452</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-01-14T00:37:03Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790116#M32455</link>
      <description>&lt;P&gt;or with an array approach plus the goodie to have the months correctly sorted.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
select distinct month into :oks separated by " "
from have order by
input(cats('01',month,'2021'), date9.);
quit;

data want;
set have;
array temp &amp;amp;oks;
do over temp;
temp=(month=vname(temp));
end;
drop month id;
run;

proc summary data=want nway;
class park;
var _numeric_;
output out=want1(drop=_:) sum= / autolabel;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jan 2022 08:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790116#M32455</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-01-14T08:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790118#M32456</link>
      <description>&lt;P&gt;or transreg design for one hot encoding&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc transreg data=have design;
   MODEL IDENTITY(id) 
         CLASS(month / zero=none );
		 ID park;
   OUTPUT OUT=want(DROP=_TYPE_ _NAME_ INTERCEPT id);
RUN;

proc sql;
select distinct name into :oks separated by " "
from dictionary.columns where libname="WORK" and memname="WANT" and type="num" order by
input(cats('01',substr(name,6,3),'2021'), date9.);
quit;

data want;
format &amp;amp;oks best12.;
set want;
run;

proc summary data=want nway;
class park;
var _numeric_;
output out=want1(drop=_:) sum= / autolabel;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 14 Jan 2022 09:18:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790118#M32456</guid>
      <dc:creator>acordes</dc:creator>
      <dc:date>2022-01-14T09:18:24Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790119#M32457</link>
      <description>&lt;P&gt;&lt;STRONG&gt;BIG&lt;/STRONG&gt; hint: whenever you have date-related values in SAS, store them as &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/basess/p0er6damfbjifwn1ih1b1tacw5zj.htm" target="_blank" rel="noopener"&gt;date values&lt;/A&gt;, and use the appropriate format to get your intended appearance. It is then much easier to have correct sorting, or do calculations.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 10:21:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790119#M32457</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-01-14T10:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790426#M32482</link>
      <description>Thanks. I have modified the question after your response. Could you help, how can I create the modified output table.</description>
      <pubDate>Sun, 16 Jan 2022 19:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790426#M32482</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2022-01-16T19:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Reshape</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790429#M32484</link>
      <description>Thanks. It works for me. I have modified my question by adding two rows in the output table that I want. Could you help how can I create the modified table, please.</description>
      <pubDate>Sun, 16 Jan 2022 21:23:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Reshape-cross-tabulate/m-p/790429#M32484</guid>
      <dc:creator>Barkat</dc:creator>
      <dc:date>2022-01-16T21:23:51Z</dc:date>
    </item>
  </channel>
</rss>

