<?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 table with incremental rows and years for columns in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468725#M119772</link>
    <description>&lt;P&gt;To save on typing, while going to 360, you might consider a two-step approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data step1;&lt;/P&gt;
&lt;P&gt;value=0;&lt;/P&gt;
&lt;P&gt;do year = &amp;amp;FirstYear to &amp;amp;CurrentYr;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;do m = 3 to 360 by 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; varname = 'm_' || put(m, z3.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can inspect that if you would like, before continuing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose data=step1 out=want (drop=_name_);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by year;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;var value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;id varname;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also consider whether you might be better off omitting step 2 entirely, and just using the data set STEP1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Jun 2018 15:10:19 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2018-06-08T15:10:19Z</dc:date>
    <item>
      <title>Create table with incremental rows and years for columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468410#M119630</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking to create a new table with 0's as data points&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want it to look like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Year/Quarter&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 3&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;6&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;9&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2014&lt;/P&gt;&lt;P&gt;2015&lt;/P&gt;&lt;P&gt;2016&lt;/P&gt;&lt;P&gt;2017&lt;/P&gt;&lt;P&gt;2018&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the year set up like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;data want_yr;&lt;BR /&gt;date=&amp;amp;FirstYear;&lt;BR /&gt;do while (date&amp;lt;=&amp;amp;CurrentYr);&lt;BR /&gt;output;&lt;BR /&gt;date = date+1;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;But I'm pretty confused on how to continue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 15:24:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468410#M119630</guid>
      <dc:creator>rrpking</dc:creator>
      <dc:date>2018-06-07T15:24:38Z</dc:date>
    </item>
    <item>
      <title>Re: Create table with incremental rows and years for columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468421#M119638</link>
      <description>&lt;P&gt;Please describe what you will do with the resulting data?&lt;/P&gt;
&lt;P&gt;There is at least one problem, you can't have&amp;nbsp; variables named 3, 6, 9 or 12.&lt;/P&gt;
&lt;P&gt;Which variables get 1 and which 0?&lt;/P&gt;
&lt;P&gt;Second I can see a lot of reasons to use quarter values of 1, 2, 3, and 4.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What values are your macro variables &amp;amp;firstyear and &amp;amp;currentyear ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For what you show so far a do loop with&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do year = &amp;amp;firstyear to &amp;amp;currentyear;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; /* assignment of the "quarter variables" would go here*/&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is simpler.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a very large number of data reasons I would likely do&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do year = &amp;amp;firstyear to &amp;amp;currentyear;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; do quarter = 1 to 4;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Put for any other values, such as your "0 1" we need some rule.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 15:44:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468421#M119638</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-06-07T15:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Create table with incremental rows and years for columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468435#M119645</link>
      <description>&lt;P&gt;As was already noted, you can't use variable names like 3, 6, 9, etc.&amp;nbsp; So you may want to replace the choices that I'm making below.&amp;nbsp; here's what I think you are after:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;do year = &amp;amp;FirstYear to &amp;amp;CurrentYr;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;retain m_03 m_06 m_09 m_12 0;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jun 2018 16:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468435#M119645</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-07T16:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create table with incremental rows and years for columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468675#M119751</link>
      <description>&lt;P&gt;That does look better! Thank you! Now I have to figure out how to make it from m_03 to m_360.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 12:49:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468675#M119751</guid>
      <dc:creator>rrpking</dc:creator>
      <dc:date>2018-06-08T12:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create table with incremental rows and years for columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468725#M119772</link>
      <description>&lt;P&gt;To save on typing, while going to 360, you might consider a two-step approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data step1;&lt;/P&gt;
&lt;P&gt;value=0;&lt;/P&gt;
&lt;P&gt;do year = &amp;amp;FirstYear to &amp;amp;CurrentYr;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;do m = 3 to 360 by 3;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; varname = 'm_' || put(m, z3.);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; output;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;end;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can inspect that if you would like, before continuing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc transpose data=step1 out=want (drop=_name_);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;by year;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;var value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;id varname;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also consider whether you might be better off omitting step 2 entirely, and just using the data set STEP1.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 15:10:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468725#M119772</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2018-06-08T15:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Create table with incremental rows and years for columns</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468818#M119795</link>
      <description>&lt;P&gt;You could simply wrap it in a macro and use a macro loop. Something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;%MACRO myMac;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; do year = &amp;amp;FirstYear to &amp;amp;CurrentYr;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; retain&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %DO I = 1 %TO 120;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; m_%EVAL(&amp;amp;I.*3)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; %END;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;%MEND;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jun 2018 18:00:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-table-with-incremental-rows-and-years-for-columns/m-p/468818#M119795</guid>
      <dc:creator>ybolduc</dc:creator>
      <dc:date>2018-06-08T18:00:59Z</dc:date>
    </item>
  </channel>
</rss>

