<?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 Concatenate Value Based on Header Name in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785657#M250764</link>
    <description>&lt;P&gt;I have the following data. The real data is about 100 columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
    input id$ cause1$ cause2$ cause3$ effect1$ effect2$ effect3$ @@@@@@@;
    datalines;
    aa 001 001 002 001 003 .
    bb 005 . . 004 005 001
    cc 001 003 002 001 003 002
    dd 002 004 009 002 005 006
    ;
run;&lt;/PRE&gt;&lt;P&gt;The codes aren't very helpful for analysis. So I'd like to add a character to the start based on the header.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 564px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66674i06A4E86D48C9C438/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Dec 2021 22:34:40 GMT</pubDate>
    <dc:creator>cobba</dc:creator>
    <dc:date>2021-12-12T22:34:40Z</dc:date>
    <item>
      <title>Concatenate Value Based on Header Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785657#M250764</link>
      <description>&lt;P&gt;I have the following data. The real data is about 100 columns&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data have;
    input id$ cause1$ cause2$ cause3$ effect1$ effect2$ effect3$ @@@@@@@;
    datalines;
    aa 001 001 002 001 003 .
    bb 005 . . 004 005 001
    cc 001 003 002 001 003 002
    dd 002 004 009 002 005 006
    ;
run;&lt;/PRE&gt;&lt;P&gt;The codes aren't very helpful for analysis. So I'd like to add a character to the start based on the header.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 564px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66674i06A4E86D48C9C438/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Dec 2021 22:34:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785657#M250764</guid>
      <dc:creator>cobba</dc:creator>
      <dc:date>2021-12-12T22:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Value Based on Header Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785664#M250771</link>
      <description>&lt;P&gt;VNAME function within an array.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set have;

array _vars(*) cause1--effect3;

do i=1 to dim(_vars);
     _vars(i) = catt(substr(vname(_vars), 1, 1), _vars(i));
end;

run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/408985"&gt;@cobba&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have the following data. The real data is about 100 columns&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
    input id$ cause1$ cause2$ cause3$ effect1$ effect2$ effect3$ @@@@@@@;
    datalines;
    aa 001 001 002 001 003 .
    bb 005 . . 004 005 001
    cc 001 003 002 001 003 002
    dd 002 004 009 002 005 006
    ;
run;&lt;/PRE&gt;
&lt;P&gt;The codes aren't very helpful for analysis. So I'd like to add a character to the start based on the header.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 564px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/66674i06A4E86D48C9C438/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&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>Mon, 13 Dec 2021 00:06:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785664#M250771</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-13T00:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Value Based on Header Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785666#M250773</link>
      <description>I'm getting the following error when I run your code. I am running SAS EG 7.1 under SAS v9.3&lt;BR /&gt;&lt;BR /&gt;ERROR: Array subscript out of range at line 39 column 30.&lt;BR /&gt;id=aa cause1=001 cause2=001 cause3=002 effect1=001 effect2=003 effect3= i=1 _ERROR_=1 _N_=1</description>
      <pubDate>Mon, 13 Dec 2021 00:25:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785666#M250773</guid>
      <dc:creator>cobba</dc:creator>
      <dc:date>2021-12-13T00:25:55Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Value Based on Header Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785668#M250775</link>
      <description>&lt;P&gt;Replace line:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; _vars(i) = catt(substr(vname(_vars), 1, 1), _vars(i));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;into:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt; _vars(i) = catt(substr(vname(_vars(i)), 1, 1), _vars(i));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Dec 2021 00:35:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785668#M250775</guid>
      <dc:creator>Shmuel</dc:creator>
      <dc:date>2021-12-13T00:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenate Value Based on Header Name</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785670#M250777</link>
      <description>&lt;P&gt;Replace the IF with this:&lt;/P&gt;
&lt;P&gt;Accounts for missing and I had missed the (i) in the array reference within the VNAME() function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;if not missing(_vars(i)) then _vars(i) = catt(substr(vname(_vars(i)), 1, 1), _vars(i));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Dec 2021 01:04:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Concatenate-Value-Based-on-Header-Name/m-p/785670#M250777</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-12-13T01:04:20Z</dc:date>
    </item>
  </channel>
</rss>

