<?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: Creating variable with a name containing value of a different variable for an observation in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-variable-with-a-name-containing-value-of-a-different/m-p/285793#M59441</link>
    <description>&lt;P&gt;Solved it myself, here's the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data out;
set in;
%let d=400;
%let e=50; *Max dimensions for the number of h's;

array name{&amp;amp;d};
array indate{&amp;amp;d};
array eh{&amp;amp;e};
h=1;
do i=1 to &amp;amp;d;
   if substr(name{i},1,4) in ("asdf", "jklo") then do;
       eh{h}=indate{i}
       h=h+1;
   end;
end;
run;&lt;/PRE&gt;</description>
    <pubDate>Wed, 20 Jul 2016 12:32:15 GMT</pubDate>
    <dc:creator>chrisengel</dc:creator>
    <dc:date>2016-07-20T12:32:15Z</dc:date>
    <item>
      <title>Creating variable with a name containing value of a different variable for an observation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-variable-with-a-name-containing-value-of-a-different/m-p/285791#M59440</link>
      <description>&lt;P&gt;Let's say I have a two columns, 1 with a bunch of names, and another with a bunch of dates:&lt;/P&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;&lt;PRE&gt;data out;
set in;
%let d=400;

array name{&amp;amp;d};
array indate{&amp;amp;d};
h=1;
do i=1 to &amp;amp;d;
   if substr(name{i},1,4) in ("asdf", "jklo") then do;
       eh&amp;amp;h=indate{i}
       h=h+1;
   end;
end;
run;&lt;/PRE&gt;&lt;P&gt;This code is able to count the number of occurnaces of names "asdf" and "jklo" and set them for each observation as "h".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when I try to create the variable "eh&amp;amp;h" with &amp;amp;h to represent the h'th occurance of the names, it doesn't work.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I make it so the variable names created to set as indate contains the value of h for a given observation?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried even to create an array using the dimension of maximum number of h's in the dataset, but that didn't work either (and may have been the wrong idae). So i come here to see if there's something i'm just missing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks ahead of time.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2016 12:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-variable-with-a-name-containing-value-of-a-different/m-p/285791#M59440</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-07-20T12:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: Creating variable with a name containing value of a different variable for an observation</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-variable-with-a-name-containing-value-of-a-different/m-p/285793#M59441</link>
      <description>&lt;P&gt;Solved it myself, here's the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;data out;
set in;
%let d=400;
%let e=50; *Max dimensions for the number of h's;

array name{&amp;amp;d};
array indate{&amp;amp;d};
array eh{&amp;amp;e};
h=1;
do i=1 to &amp;amp;d;
   if substr(name{i},1,4) in ("asdf", "jklo") then do;
       eh{h}=indate{i}
       h=h+1;
   end;
end;
run;&lt;/PRE&gt;</description>
      <pubDate>Wed, 20 Jul 2016 12:32:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-variable-with-a-name-containing-value-of-a-different/m-p/285793#M59441</guid>
      <dc:creator>chrisengel</dc:creator>
      <dc:date>2016-07-20T12:32:15Z</dc:date>
    </item>
  </channel>
</rss>

