<?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: %do year %to year in SET statement in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113289#M31376</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The OF operator can also be used to eliminate the need for the commas.&lt;/P&gt;&lt;P&gt;total=sum(of f2000-f2011);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 31 Oct 2012 17:11:05 GMT</pubDate>
    <dc:creator>ArtC</dc:creator>
    <dc:date>2012-10-31T17:11:05Z</dc:date>
    <item>
      <title>%do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113280#M31367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I just have a very simple question for a code I used before but just wouldn't work now. Basically I just wanted to use %do year %to year to stack up a series of data sets from multiple years. The example I'm using below is just for 3 years. For some reasons the following code isn't working&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data combined; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set %do year = 2009 %to 2011; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d&amp;amp;year &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;and would give me error messages "%DO statement is not valid in open code" and pointed to d&amp;amp;year as&lt;/P&gt;&lt;P&gt;- Syntax error, expecting one of the following: a name, a quoted string, (, -, :,;, END, INDSNAME, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_.&lt;/P&gt;&lt;P&gt;- The symbol is not recognized and will be ignored.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Same data are below. Thanks a great deal. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data d2009; input&lt;/P&gt;&lt;P&gt;id;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;2&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data d2010; input&lt;/P&gt;&lt;P&gt;id;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;5&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data d2011; input&lt;/P&gt;&lt;P&gt;id;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;3&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;data combined; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set %do year = 2009 %to 2011; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; d&amp;amp;year &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; %end;;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 15:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113280#M31367</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-10-31T15:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: %do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113281#M31368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;%do is only valid if it is part of a SAS macro that you create.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 16:03:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113281#M31368</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-10-31T16:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: %do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113282#M31369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well the log is right, you can't do that in open code, that's macro code, so you can wrap all of your code in macro or use something different.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ie&lt;/P&gt;&lt;P&gt;data combined;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set d2009-d2011 indsname=temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dsname=temp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data combined2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set d20: indsname=temp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dsname=temp;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 16:04:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113282#M31369</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-10-31T16:04:12Z</dc:date>
    </item>
    <item>
      <title>Re: %do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113283#M31370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Arthur. It's really stupid of me totally forgetting about it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reeza, what do indsname and dsname do? Any hint is appreciated and I'll then google to find more about it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 16:09:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113283#M31370</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-10-31T16:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: %do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113284#M31371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/34/513.html" title="http://support.sas.com/kb/34/513.html"&gt;http://support.sas.com/kb/34/513.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;dsname was just a variable that Reeza created.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 16:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113284#M31371</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2012-10-31T16:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: %do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113285#M31372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Arthur.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;While I'm on it, I've another related, but not so related question. I want to create a variable based on the sum of a series of variable ending in numerical order. Is there any shortcut to do it. (I can't use f2000-f2011 since I need comma in between variables to do sum or average,).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;total=sum(f2000,f2001,f2002,f2003,f2004,f2005,f2006,f2007,f2008,f2009,f2010,f2011);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 16:14:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113285#M31372</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-10-31T16:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: %do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113286#M31373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could create an array or use the colon operator if your variables are name f20XX consistently.&lt;/P&gt;&lt;P&gt;Double check to make sure its giving you what you wanted.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; array test(10) var1-var10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to 10;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; test(i)=5;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; total=sum(of test(*));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; total2=sum(of var:);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 16:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113286#M31373</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-10-31T16:23:59Z</dc:date>
    </item>
    <item>
      <title>Re: %do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113287#M31374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;indsname is a SAS option that stores the name of the source dataset when stacking multiples together that I remember by &lt;STRONG&gt;IN&lt;/STRONG&gt; &lt;STRONG&gt;D&lt;/STRONG&gt;ata&lt;STRONG&gt;S&lt;/STRONG&gt;et &lt;STRONG&gt;NAME&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;And dsname is just a variable created to store the value.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 16:25:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113287#M31374</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2012-10-31T16:25:41Z</dc:date>
    </item>
    <item>
      <title>Re: %do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113288#M31375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for all the tips and info. It's such a great community for help. I really appreciate it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 16:43:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113288#M31375</guid>
      <dc:creator>Solph</dc:creator>
      <dc:date>2012-10-31T16:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: %do year %to year in SET statement</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113289#M31376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The OF operator can also be used to eliminate the need for the commas.&lt;/P&gt;&lt;P&gt;total=sum(of f2000-f2011);&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 31 Oct 2012 17:11:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/do-year-to-year-in-SET-statement/m-p/113289#M31376</guid>
      <dc:creator>ArtC</dc:creator>
      <dc:date>2012-10-31T17:11:05Z</dc:date>
    </item>
  </channel>
</rss>

