<?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: Declaring an array of &amp;quot;YYYYMM&amp;quot; columns in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265975#M57928</link>
    <description>&lt;P&gt;SAS variable ranges are simply numbers. There is no such thing as a SAS variable "date range". I'd also say it is probably not good practice to hard-code dates into variable names as you lose a lot of flexibility. For example if your table just contained the last 12 month's data, each month your variables would change name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not consider naming your columns like month1 to month12 (or how ever many you want) then add a start_month and an end_month variable to specify the start and the end of the range?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 25 Apr 2016 09:08:10 GMT</pubDate>
    <dc:creator>SASKiwi</dc:creator>
    <dc:date>2016-04-25T09:08:10Z</dc:date>
    <item>
      <title>Declaring an array of "YYYYMM" columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265967#M57925</link>
      <description>&lt;P&gt;I have a wide dataset where a series of columns are named _201507, _201508, ..., _201603, to indicate the value of a variable during a specific month. I want to create an array of _201507-_201603.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried the following code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;array period(*) _201507-_201603;&lt;BR /&gt;SumPeriod = sum(of _201507-_201603);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem with this code is that SAS doesn't realize that column _201512 is followed by column _201601. Instead it creates columns _201513 through to _201600 which is clearly not what I want.&lt;/P&gt;&lt;P&gt;How can I get around this issue?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 08:49:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265967#M57925</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-04-25T08:49:58Z</dc:date>
    </item>
    <item>
      <title>Re: Declaring an array of "YYYYMM" columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265970#M57926</link>
      <description>If they are set next to each other. Try :

&lt;PRE&gt;
array period(*) _201507--_201603;

&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Apr 2016 09:00:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265970#M57926</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-25T09:00:43Z</dc:date>
    </item>
    <item>
      <title>Re: Declaring an array of "YYYYMM" columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265973#M57927</link>
      <description>&lt;P&gt;Thank you for your help. This solved my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the original dataset, the columns were ordered randomly. I used the Query Builder in SAS EG to order them chronologically next to each other. Is there any faster way of ordering columns in situations like these?&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 09:07:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265973#M57927</guid>
      <dc:creator>udden2903</dc:creator>
      <dc:date>2016-04-25T09:07:09Z</dc:date>
    </item>
    <item>
      <title>Re: Declaring an array of "YYYYMM" columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265975#M57928</link>
      <description>&lt;P&gt;SAS variable ranges are simply numbers. There is no such thing as a SAS variable "date range". I'd also say it is probably not good practice to hard-code dates into variable names as you lose a lot of flexibility. For example if your table just contained the last 12 month's data, each month your variables would change name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why not consider naming your columns like month1 to month12 (or how ever many you want) then add a start_month and an end_month variable to specify the start and the end of the range?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Apr 2016 09:08:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265975#M57928</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2016-04-25T09:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Declaring an array of "YYYYMM" columns</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265977#M57929</link>
      <description>I would do this. But it is not efficient .

&lt;PRE&gt;

data have;
retain _id 2;
array x{*} _201602 _201511 _201512 _201601 (4*1);
run;
proc sql;
 select name into : list separated by ' '
  from dictionary.columns
   where libname='WORK' and memname='HAVE' 
    and prxmatch('/^_\d{6}$/',strip(name))
     order by input(substr(name,2),best32.);
quit;


%put NOTE: &amp;amp;list  ;
&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Apr 2016 09:23:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Declaring-an-array-of-quot-YYYYMM-quot-columns/m-p/265977#M57929</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-04-25T09:23:59Z</dc:date>
    </item>
  </channel>
</rss>

