<?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: How do you join arrays or list multiple column names in a single array? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611126#M178062</link>
    <description>&lt;P&gt;FYI - this is bad data structure, you should reformat your data to be in columns with time as a row. &lt;BR /&gt;Then your analysis can be simplified massively. &lt;BR /&gt;&lt;BR /&gt;This would follow the principles of tidy data that allow for more efficient analysis. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html" target="_blank" rel="noopener"&gt;https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Column headers that contain data, not just variables are problematic in this structure. &lt;/P&gt;</description>
    <pubDate>Wed, 11 Dec 2019 20:15:20 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2019-12-11T20:15:20Z</dc:date>
    <item>
      <title>How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611120#M178057</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following columns: Cum_Rev_0-Cum_Rev_24 Cum_NCO_0-Cum_NCO_24 Cum_Net_0-Cum_Net_24&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to join these arrays to help minimize the code being used here instead of duplicating each line? I know I can do this with a macro but looking to see if there are alternatives.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was thinking there might be a way to use a wild card or something in the middle e.g. Cum_***_0-Cum_***_24 or is this not possible?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cum_net_rev2;
set cum_net_rev1;
format today mmddyy.;
today = today();
array cum_rev_{25} cum_rev_0 - cum_rev_24;

do i = 1 to 25;
    if intck('month', business_date, today) &amp;gt;= i then cum_rev_{i} = cum_rev_{i};
    else cum_rev_{i} = .;
end;&lt;BR /&gt;&lt;BR /&gt;/*Duplicate row for cum_nco_{i} rows*/
array cum_nco_{25} cum_nco_0 - cum_nco_24;

do i = 1 to 25;
    if intck('month', business_date, today) &amp;gt;= i then cum_nco_{i} = cum_nco_{i};
    else cum_nco_{i} = .;
end;&lt;BR /&gt;&lt;BR /&gt;/*Duplicate row for cum_net_{i} rows*/
array cum_net_{25} cum_net_0 - cum_net_24;

do i = 1 to 25;
    if intck('month', business_date, today) &amp;gt;= i then cum_net_{i} = cum_net_{i};
    else cum_net_{i} = .;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 20:03:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611120#M178057</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2019-12-11T20:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611121#M178058</link>
      <description>&lt;P&gt;Here is a reference that illustrates how to refer to variables and datasets in a short cut list:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2018/05/29/6-easy-ways-to-specify-a-list-of-variables-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/295821"&gt;@Krueger&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have the following columns: Cum_Rev_0-Cum_Rev_24 Cum_NCO_0-Cum_NCO_24 Cum_Net_0-Cum_Net_24&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there a way to join these arrays to help minimize the code being used here instead of duplicating each line? I know I can do this with a macro but looking to see if there are alternatives.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was thinking there might be a way to use a wild card or something in the middle e.g. Cum_***_0-Cum_***_24 or is this not possible?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data cum_net_rev2;
set cum_net_rev1;
format today mmddyy.;
today = today();
array cum_rev_{25} cum_rev_0 - cum_rev_24;

do i = 1 to 25;
    if intck('month', business_date, today) &amp;gt;= i then cum_rev_{i} = cum_rev_{i};
    else cum_rev_{i} = .;
end;&lt;BR /&gt;/*Duplicate row for cum_nco_{i} rows*/
array cum_nco_{25} cum_nco_0 - cum_nco_24;

do i = 1 to 25;
    if intck('month', business_date, today) &amp;gt;= i then cum_nco_{i} = cum_nco_{i};
    else cum_nco_{i} = .;
end;&lt;BR /&gt;/*Duplicate row for cum_net_{i} rows*/
array cum_net_{25} cum_net_0 - cum_net_24;

do i = 1 to 25;
    if intck('month', business_date, today) &amp;gt;= i then cum_net_{i} = cum_net_{i};
    else cum_net_{i} = .;
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 20:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611121#M178058</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-11T20:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611125#M178061</link>
      <description>&lt;P&gt;What is it your code is trying to do?&amp;nbsp; The action in the THEN clause of this seems strange:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    if intck('month', business_date, today) &amp;gt;= i then cum_rev_{i} = cum_rev_{i};
    else cum_rev_{i} = .;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You are essentially doing:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;    if not (intck('month', business_date, today) &amp;gt;= i) then cum_rev_{i} = .;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You could create a 2-D array and add another DO loop.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;array cumm[3,25] Cum_Rev_0-Cum_Rev_24 Cum_NCO_0-Cum_NCO_24 Cum_Net_0-Cum_Net_24;
do i=1 to 25 ;
  if not (intck('month', business_date, today) &amp;gt;= i) then do j=1 to 3;
    cumm[j,i] = .;
  end;
end;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 20:11:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611125#M178061</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-12-11T20:11:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611126#M178062</link>
      <description>&lt;P&gt;FYI - this is bad data structure, you should reformat your data to be in columns with time as a row. &lt;BR /&gt;Then your analysis can be simplified massively. &lt;BR /&gt;&lt;BR /&gt;This would follow the principles of tidy data that allow for more efficient analysis. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html" target="_blank" rel="noopener"&gt;https://cran.r-project.org/web/packages/tidyr/vignettes/tidy-data.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Column headers that contain data, not just variables are problematic in this structure. &lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 20:15:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611126#M178062</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-11T20:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611127#M178063</link>
      <description>&lt;P&gt;You are correct, I'm just over complicating things trying to learn and experiment with new things.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is what I am doing.&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt; &lt;SPAN class="token keyword"&gt;if&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;not&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;intck&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'month'&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; business_date&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;today&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;&amp;gt;=&lt;/SPAN&gt; i&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;then&lt;/SPAN&gt; cum_rev_&lt;SPAN class="token punctuation"&gt;{&lt;/SPAN&gt;i&lt;SPAN class="token punctuation"&gt;}&lt;/SPAN&gt; &lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt; &lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 20:25:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611127#M178063</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2019-12-11T20:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611128#M178064</link>
      <description>&lt;P&gt;Thanks I wasn't aware of alot of this stuff!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 20:14:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611128#M178064</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2019-12-11T20:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611130#M178065</link>
      <description>Yeah, data structure isn't something that's covered in most courses but understanding those concepts can help make you a lot more efficient. And these are principles that hold regardless of programming knowledge.</description>
      <pubDate>Wed, 11 Dec 2019 20:16:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611130#M178065</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-11T20:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611133#M178067</link>
      <description>&lt;P&gt;I think I understand what your saying here (I had to do some proc transposes earlier) but basically this analysis is breaking down a time period (in this instance it is the months) and doing cumulative counts on Revenue, Debt and Net from the month since the start of the loan. We then track this for each month from the start of the loan.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;At the end we're grouping all of this data by loan into current time periods so it would like something like this...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;MonthYear Campaign CUM_REV_1-CUM_REV_3 CUM_NCO_1-CUM_NCO_3 CUM_NET_1-CUM_NET_3&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully that made sense?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 20:23:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611133#M178067</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2019-12-11T20:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611135#M178069</link>
      <description>Why?&lt;BR /&gt;Why not have that in a long format instead of wide with just three variables, especially when you have a month/year alread yin the data. The cumulative measures are redundant in some measure if they're lagged, aren't they?</description>
      <pubDate>Wed, 11 Dec 2019 20:28:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611135#M178069</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-12-11T20:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611142#M178072</link>
      <description>&lt;P&gt;Well, because the final output isn't that simple.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is a snippet with values removed showing some but not all of the columns. There are multiple groupings for Campaign_customer, customer_group and product_name which are all broken out by business_date. We then have the cum_: fields for each of these.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Example.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/34682iA6C1A0990413F0AA/image-size/large?v=v2&amp;amp;px=999" role="button" title="Example.PNG" alt="Example.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 20:39:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611142#M178072</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2019-12-11T20:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: How do you join arrays or list multiple column names in a single array?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611156#M178074</link>
      <description>&lt;P&gt;Thanks I wasn't aware of 2-D arrays!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2019 20:54:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-do-you-join-arrays-or-list-multiple-column-names-in-a-single/m-p/611156#M178074</guid>
      <dc:creator>Krueger</dc:creator>
      <dc:date>2019-12-11T20:54:27Z</dc:date>
    </item>
  </channel>
</rss>

