<?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 SAS Array Elements - use in any subsequent DATA step in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-Elements-use-in-any-subsequent-DATA-step/m-p/202834#M37828</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working to clean-up some previous SAS hacker's copy/paste technique. These SAS routines have several dozen DATA steps.&lt;/P&gt;&lt;P&gt;At the beginning of the routine, I would like to read a set of Term Codes and Dates into an array and then reference that anywhere in the program.&lt;/P&gt;&lt;P&gt;Currently, the ARRAY statement and reference works only within the SAME Data Step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Such that TermCode[1] = 2013-1, TermCode[2] = 2013-2, TermCode[3] = 2013-3...........etc&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TermDate[1]= 19183, TermDate[2]=19274 ...........etc (SAS DATES).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So later in the program (about 20 data steps), I can say for&lt;/P&gt;&lt;P&gt;TCidx = 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;ChkDate = TermDate[TCidx];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now I just get ERROR: Undeclared array referenced: TermDate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on creating GLOBAL variable that is an array. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Jul 2015 23:39:34 GMT</pubDate>
    <dc:creator>IsoTropic</dc:creator>
    <dc:date>2015-07-14T23:39:34Z</dc:date>
    <item>
      <title>SAS Array Elements - use in any subsequent DATA step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-Elements-use-in-any-subsequent-DATA-step/m-p/202834#M37828</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am working to clean-up some previous SAS hacker's copy/paste technique. These SAS routines have several dozen DATA steps.&lt;/P&gt;&lt;P&gt;At the beginning of the routine, I would like to read a set of Term Codes and Dates into an array and then reference that anywhere in the program.&lt;/P&gt;&lt;P&gt;Currently, the ARRAY statement and reference works only within the SAME Data Step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Such that TermCode[1] = 2013-1, TermCode[2] = 2013-2, TermCode[3] = 2013-3...........etc&lt;/P&gt;&lt;P&gt;and&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TermDate[1]= 19183, TermDate[2]=19274 ...........etc (SAS DATES).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So later in the program (about 20 data steps), I can say for&lt;/P&gt;&lt;P&gt;TCidx = 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;ChkDate = TermDate[TCidx];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;now I just get ERROR: Undeclared array referenced: TermDate.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions on creating GLOBAL variable that is an array. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Jul 2015 23:39:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-Elements-use-in-any-subsequent-DATA-step/m-p/202834#M37828</guid>
      <dc:creator>IsoTropic</dc:creator>
      <dc:date>2015-07-14T23:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array Elements - use in any subsequent DATA step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-Elements-use-in-any-subsequent-DATA-step/m-p/202835#M37829</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The ARRAY statement is a data step statement that just creates an alias that you can use during that data step to make it easier to access a set of variables. It does not make anything permanent that will survive from one data step to another.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you have rational variable names the ARRAY statements are not hard to write.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data step2;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set step1;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array TermCode TermCode: ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array TermDate&amp;nbsp; TermDate: ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could store the list of variables or the ARRAY statement itself into a macro variable to make it easier to replicate in many places.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 00:05:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-Elements-use-in-any-subsequent-DATA-step/m-p/202835#M37829</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2015-07-15T00:05:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array Elements - use in any subsequent DATA step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-Elements-use-in-any-subsequent-DATA-step/m-p/202836#M37830</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Tom said, arrays are not global. Macro variable can be.&lt;/P&gt;&lt;P&gt;Just call the array declaration as needed:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; codes&amp;nbsp; = '2003-01' '2003-02';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; dates&amp;nbsp; = 19183&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 19274&amp;nbsp; ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%let&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; arrays =&amp;nbsp; array termcodes [2] $8 _temporary_ (&amp;amp;codes)&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&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;&amp;nbsp;&amp;nbsp; array termdates [2]&amp;nbsp; 4 _temporary_ (&amp;amp;dates)&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;%str&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;(;);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; TEST;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp; &amp;amp;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: teal; background: white;"&gt;arrays.&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;put&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&amp;nbsp;&amp;nbsp; termdates[&lt;/SPAN&gt;&lt;SPAN style="color: teal; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;1&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: navy; background: white; font-size: 10.0pt; font-family: 'Courier New';"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 11:07:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-Elements-use-in-any-subsequent-DATA-step/m-p/202836#M37830</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2015-07-15T11:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: SAS Array Elements - use in any subsequent DATA step</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-Array-Elements-use-in-any-subsequent-DATA-step/m-p/202837#M37831</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Chris your example is excellent and to the point.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I tried your sample code and it does make the termdates&lt;X&gt; available in any subsequent DATA steps as long as &amp;amp;array. is declared for each data step that needs to use the array references.&lt;/X&gt;&lt;/P&gt;&lt;P&gt;By using the &amp;amp;arrays. this must instantiate the macro variables for that DATA step.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jul 2015 15:31:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-Array-Elements-use-in-any-subsequent-DATA-step/m-p/202837#M37831</guid>
      <dc:creator>IsoTropic</dc:creator>
      <dc:date>2015-07-15T15:31:39Z</dc:date>
    </item>
  </channel>
</rss>

