<?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: 2 way table with a twist- help! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/505669#M135447</link>
    <description>&lt;P&gt;If you have a working SQL code to make a crosstab it may, depending on what version you have, be convertible into SAS PROC SQL code. May. The idea behind crosstabs is pretty much contrary to normalized data that SQL is designed for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you don't provide any example input data, any variable names or types or any rules for what gets "crosstabbed" not much detail can be provided.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Oct 2018 17:40:02 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-10-18T17:40:02Z</dc:date>
    <item>
      <title>2 way table with a twist- help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/505609#M135422</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a new SAS user.&lt;/P&gt;&lt;P&gt;I'm looking to replicate a SQL crosstab query in SAS.&lt;/P&gt;&lt;P&gt;The query in question has columns which are days of the month (from 1 - 31) whilst the columns are of months and corresponding values within.&lt;/P&gt;&lt;P&gt;Ive tried using my date values and proc tabulate but without many positive results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many many thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;Please see the SQL access example below:&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="sasexample1.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24140i711CDFE3C474E843/image-size/large?v=v2&amp;amp;px=999" role="button" title="sasexample1.png" alt="sasexample1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 15:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/505609#M135422</guid>
      <dc:creator>Michael_B-T</dc:creator>
      <dc:date>2018-10-18T15:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: 2 way table with a twist- help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/505618#M135427</link>
      <description>&lt;P&gt;Hi, welcome to the SAS Forums.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately there is not enough information in your post to answer your question.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is that what you have, or what you want? You need to&amp;nbsp;provide:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;what you have to start with&lt;/LI&gt;
&lt;LI&gt;what you want as the output&lt;/LI&gt;
&lt;LI&gt;and, preferably, what you've tried so far&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Then someone should be able to help you answer your question.&amp;nbsp; It may also help to provide the previous SQL query. SAS supports SQL so depending on how complex of a query it is, you may just be able to wrap it in PROC SQL statements. However SAS does not support Pivots or Windowing functions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/241234"&gt;@Michael_B-T&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm a new SAS user.&lt;/P&gt;
&lt;P&gt;I'm looking to replicate a SQL crosstab query in SAS.&lt;/P&gt;
&lt;P&gt;The query in question has columns which are days of the month (from 1 - 31) whilst the columns are of months and corresponding values within.&lt;/P&gt;
&lt;P&gt;Ive tried using my date values and proc tabulate but without many positive results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any tips?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many many thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Please see the SQL access example below:&lt;span class="lia-inline-image-display-wrapper lia-image-align-center" image-alt="sasexample1.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24140i711CDFE3C474E843/image-size/large?v=v2&amp;amp;px=999" role="button" title="sasexample1.png" alt="sasexample1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 15:48:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/505618#M135427</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-18T15:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: 2 way table with a twist- help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/505669#M135447</link>
      <description>&lt;P&gt;If you have a working SQL code to make a crosstab it may, depending on what version you have, be convertible into SAS PROC SQL code. May. The idea behind crosstabs is pretty much contrary to normalized data that SQL is designed for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you don't provide any example input data, any variable names or types or any rules for what gets "crosstabbed" not much detail can be provided.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Oct 2018 17:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/505669#M135447</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-18T17:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: 2 way table with a twist- help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/505673#M135449</link>
      <description>&lt;P&gt;Looks like all you need is to transpose some data. An example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
call streaminit(65651);
do date = '01JAN2017'd to '31DEC2017'd;
    if weekday(date) in (1, 7) then call missing(value);
    else value = rand("Poisson", 100);
    month = intnx("month", date, 0);
    day = day(date);
    output;
    end;
format month mmyys7.;
run;

proc transpose data=test out=want(drop=_name_) prefix=day_;
by month;
id day;
var value;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 18 Oct 2018 17:54:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/505673#M135449</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-10-18T17:54:02Z</dc:date>
    </item>
    <item>
      <title>Re: 2 way table with a twist- help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/506444#M135776</link>
      <description>&lt;P&gt;HI PGStats&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for that!&lt;/P&gt;&lt;P&gt;Very helpful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Playing around with the code I would like to embed instead of the random values some values from another table in correspondence to the dates.&lt;/P&gt;&lt;P&gt;This is what I tried&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set PART2;
do sesdate_DATE = '01JAN2018'd to '31DEC2018'd;
    if weekday(sesdate_DATE) in (1, 7) then call missing(enratt);
	else value = enratt;
    month = intnx("month", sesdate_DATE, 0);
    day = day(sesdate_DATE);
    output;
    end;
format month mmyys7.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;With "enratt" being the name of the column with the actual values and sesdate_DATE actual dates.&lt;/P&gt;&lt;P&gt;The problem with the above is that I receive lots of 0s and . instead of the actual values from the table called Part2 in the Value column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any tips?&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;</description>
      <pubDate>Mon, 22 Oct 2018 13:55:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/506444#M135776</guid>
      <dc:creator>Michael_B-T</dc:creator>
      <dc:date>2018-10-22T13:55:07Z</dc:date>
    </item>
    <item>
      <title>Re: 2 way table with a twist- help!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/506542#M135809</link>
      <description>&lt;P&gt;To use your own data, you only need to add month and day, and make sure the data is sorted:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
set PART2;
value = enratt;
month = intnx("month", sesdate_DATE, 0);
day = day(sesdate_DATE);
format month mmyys7.;
run;

proc sort data=test; by month day; run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 22 Oct 2018 17:31:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/2-way-table-with-a-twist-help/m-p/506542#M135809</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2018-10-22T17:31:04Z</dc:date>
    </item>
  </channel>
</rss>

