<?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: Create a New Variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-New-Variable/m-p/440206#M109926</link>
    <description>&lt;P&gt;The data is already set out that way in production (I just sent dummy data across) and I want to create a tabulate on the back of the data but there will be too many dimensions (unless I am doing the tabulate wrong).&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Feb 2018 15:31:49 GMT</pubDate>
    <dc:creator>Brandon16</dc:creator>
    <dc:date>2018-02-26T15:31:49Z</dc:date>
    <item>
      <title>Create a New Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-New-Variable/m-p/440169#M109913</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this dummy code (only a section as this goes up to December) below where I have sum for each variable. How do I group this into one variable so my next part of code referencing the table will look at variable 'x' instead of having to type out each individual variable name again?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I basically want&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sum(jancount) as onecount,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sum(janvalue) as onevalue,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sum(febcount) as twocount,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sum(febvalue) as twovalue,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sum(marcount) as threecount,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sum(marvalue) as threevalue&lt;STRONG&gt; as all_data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;create table test.test_cas as&lt;BR /&gt;select&lt;BR /&gt;pydate,&lt;BR /&gt;sum(jancount) as onecount,&lt;BR /&gt;sum(janvalue) as onevalue,&lt;BR /&gt;sum(febcount) as twocount,&lt;BR /&gt;sum(febvalue) as twovalue,&lt;BR /&gt;sum(marcount) as threecount,&lt;BR /&gt;sum(marvalue) as threevalue&lt;BR /&gt;from test.testing&lt;BR /&gt;group by pydate;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 12:51:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-New-Variable/m-p/440169#M109913</guid>
      <dc:creator>Brandon16</dc:creator>
      <dc:date>2018-02-26T12:51:36Z</dc:date>
    </item>
    <item>
      <title>Re: Create a New Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-New-Variable/m-p/440172#M109914</link>
      <description>&lt;P&gt;Your making it difficult for yourself.&amp;nbsp; It is never a good idea to put data observations in colums - i.e. rather than this:&lt;/P&gt;
&lt;P&gt;jancount&amp;nbsp; janvalue&amp;nbsp; febcount febvalue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which is very hard to program with, and not good data storage (what happens at end of year, overlaps etc.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A simpler, better solution:&lt;/P&gt;
&lt;P&gt;Date&amp;nbsp; &amp;nbsp;Count&amp;nbsp; Value&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With this you can simply summarise the data using proc means/summary.&amp;nbsp; The date value can be formatted as month, but would be expandable across years, sub dividable out and generally far more usable.&amp;nbsp; Just your code you present there, having to type in manually each variable name is a real pain, SQL is designed to work with normalised data (as I showed), not transposed, and even SAS which has some shortcuts doesn't work that great with transposed data.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 13:14:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-New-Variable/m-p/440172#M109914</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-02-26T13:14:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create a New Variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-New-Variable/m-p/440206#M109926</link>
      <description>&lt;P&gt;The data is already set out that way in production (I just sent dummy data across) and I want to create a tabulate on the back of the data but there will be too many dimensions (unless I am doing the tabulate wrong).&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Feb 2018 15:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-New-Variable/m-p/440206#M109926</guid>
      <dc:creator>Brandon16</dc:creator>
      <dc:date>2018-02-26T15:31:49Z</dc:date>
    </item>
  </channel>
</rss>

