<?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: Loop Through Multiple Datasets and Create Field based on Dataset Name? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324306#M71986</link>
    <description>&lt;P&gt;The need to do this arose from requiring a chart listing and each code of A01 etc. means something different.&amp;nbsp; So if a chart had two codes then I want the chart to show up twice in the listing, once with HH = A01 and one with HH = A02.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried as Glen suggested but because the chart is only in the main list once, the second HH would overwrite the first, not add the chart to the group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I tried to split out&amp;nbsp; so that there was one chart per HH so I could then dynamically assign HH (i.e. A01 and A02)&amp;nbsp;and then merge back together to have one line per chart where an HH occurred, where a chart that had more than one HH would be in the list twice.&amp;nbsp; I didn't want to have to create the HH field per the 30 datasets and then merge together due to amount of code thus my query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if there is an easier way, I am all ears!&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Jan 2017 16:20:37 GMT</pubDate>
    <dc:creator>shellp55</dc:creator>
    <dc:date>2017-01-12T16:20:37Z</dc:date>
    <item>
      <title>Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324295#M71982</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using SAS 9.4.&amp;nbsp; I have a dataset of wide data i.e. chart_num, acct_num, disch_date, A01, A02, A03 etc.&amp;nbsp; I created datasets from if A01 &amp;gt; 0 then dataset A01 etc. Now I'd like to loop through the datasets and assign a field of HH = dataset name so I can merge them together.&amp;nbsp; Therefore dataset A01 will have a field of HH with "A01" and dataset A02 will have a field of HH with "A02" etc.&amp;nbsp;but do this programatically.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How would I do this?&amp;nbsp;&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 16:03:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324295#M71982</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2017-01-12T16:03:58Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324296#M71983</link>
      <description>&lt;P&gt;I would think this would be much easier to do in the orginal split.&lt;/P&gt;
&lt;P&gt;Instead of the code line you showed as: if A01 &amp;gt; 0 then dataset A01&amp;nbsp;;&lt;/P&gt;
&lt;P&gt;use&lt;/P&gt;
&lt;P&gt;if A01 &amp;gt; 0 then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; HH='A01';&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; output A01;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 16:09:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324296#M71983</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-12T16:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324301#M71985</link>
      <description>&lt;P&gt;So you have data together, you split it apart, and merge it back together?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ummmm..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What are you really wanting to do?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 16:13:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324301#M71985</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2017-01-12T16:13:54Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324306#M71986</link>
      <description>&lt;P&gt;The need to do this arose from requiring a chart listing and each code of A01 etc. means something different.&amp;nbsp; So if a chart had two codes then I want the chart to show up twice in the listing, once with HH = A01 and one with HH = A02.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried as Glen suggested but because the chart is only in the main list once, the second HH would overwrite the first, not add the chart to the group.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I tried to split out&amp;nbsp; so that there was one chart per HH so I could then dynamically assign HH (i.e. A01 and A02)&amp;nbsp;and then merge back together to have one line per chart where an HH occurred, where a chart that had more than one HH would be in the list twice.&amp;nbsp; I didn't want to have to create the HH field per the 30 datasets and then merge together due to amount of code thus my query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But if there is an easier way, I am all ears!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 16:20:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324306#M71986</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2017-01-12T16:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324313#M71990</link>
      <description>&lt;P&gt;Sorry, your not making any sense. &amp;nbsp;Start again. &amp;nbsp;Post example test data, in the form of a datastep. &amp;nbsp;Then show what the output should look like. &amp;nbsp;Then clearly state any other requirements. &amp;nbsp;There is never &amp;nbsp;need to split data up to set it back together again, you have arrays for transposed data and normalisation and other techniques to deal with these kinds of things.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 16:26:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324313#M71990</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-12T16:26:39Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324324#M71993</link>
      <description>&lt;P&gt;&lt;SPAN&gt;data test_grp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;input @1 chartno $5.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&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; @6 acctno&amp;nbsp; $5.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&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; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/30987"&gt;@11&lt;/a&gt; A01&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&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; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/70859"&gt;@12&lt;/a&gt; A02&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&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; &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83330"&gt;@13&lt;/a&gt; A03&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $1.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&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; @14 A04&amp;nbsp;&amp;nbsp;&amp;nbsp; $1.;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;cards;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;11111222220101&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;22222333331000&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;33333444440010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;44444555551100&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;55555666660010&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;A01 to A04 is&amp;nbsp;a series of criteria and any that are true I want the true value to become the field of HH and I want one line of data PER true HH.&amp;nbsp; The example below is what I would like where, for example, chart 11111 had positive A02 and A04 values so there are two obs for the one chart and the positive fields of A02 and A04 have become the HH values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1111122222A02&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;1111122222A04&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;2222233333A01&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;3333344444A03&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4444455555A01&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;4444455555A02&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="margin: 0in 0in 0pt;"&gt;&lt;SPAN&gt;&lt;FONT color="#000000" face="Calibri" size="3"&gt;5555566666A03&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your assistance.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 16:40:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324324#M71993</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2017-01-12T16:40:38Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324329#M71994</link>
      <description>&lt;P&gt;But what are you really trying to do?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Count things?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You want the number of charts with AO1?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test_grp;
input @1 chartno $5.
               @6 acctno  $5.
               @11 A01            $1.
               @12 A02            $1.
               @13 A03            $1.
               @14 A04    $1.;
cards;
11111222220101
22222333331000
33333444440010
44444555551100
55555666660010
run; 

data a01_is_one;
	set test_grp;
	if A01 = 1;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 16:46:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324329#M71994</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2017-01-12T16:46:37Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324332#M71996</link>
      <description>&lt;P&gt;I would like a dataset where each positive data element of A01 to A04 has an observation so I can create a chart list based on each of the qualifier of A01 etc.&amp;nbsp; If the chart has more than one criteria&amp;nbsp;I want the chart to show up in the list more than once.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I'm not trying to summarize or count, I'm just trying to get a dataset with each of the HH values having one observation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 16:51:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324332#M71996</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2017-01-12T16:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324336#M71997</link>
      <description>&lt;P&gt;Here are two options:&lt;/P&gt;
&lt;PRE&gt;data test_grp;
input @1 chartno $5.
               @6 acctno  $5.
               @11 A01            $1.
               @12 A02            $1.
               @13 A03            $1.
               @14 A04    $1.;
 
cards;
11111222220101
22222333331000
33333444440010
44444555551100
55555666660010
run;

data want (drop=a0:);
  set test_grp;
  array vars{*} a0:;
  do i=1 to dim(vars);
    if vars{i}="1" then do;
      actual=vname(vars{i});
      output;
    end;
  end;
run;

/* Option 2 */
proc transpose data=test_grp out=want2;
  by chartno acctno;
  var a0:;
run;
data want2;
  set want2 (where=(col1="1"));
run;

&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Jan 2017 17:01:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324336#M71997</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-01-12T17:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324338#M71998</link>
      <description>&lt;P&gt;I think you are focused on the wrong thing and have the cart before the horse, although I may not fully understand your situation. Apologies if I give offense. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can "create a chart list" of all the A01 charts and all the A02 charts and all the A03 charts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The code I just posted is a list of all the A01 charts, for example. You can do the same thing to create a list of all the A02 charts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 17:06:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324338#M71998</guid>
      <dc:creator>HB</dc:creator>
      <dc:date>2017-01-12T17:06:16Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324343#M71999</link>
      <description>&lt;P&gt;Hey RW9, this is great, thanks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For either of your options, what if the prefix to the field wasn't A i.e. there was A01 to A04, B13, C19 etc.&amp;nbsp; How would that change the code?&amp;nbsp; Or would I need to run the same for each iteration and then merge?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 17:11:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324343#M71999</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2017-01-12T17:11:42Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324344#M72000</link>
      <description>&lt;P&gt;Take a closer look at Option 1 here.&amp;nbsp; There are just a couple of items to consider.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First, instead of the variable name ACTUAL, you would be looking to use HH:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HH = vname(vars{i});&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Second, your test data shows values of "0" or "1" only.&amp;nbsp; But your question mentions values greater than 0.&amp;nbsp; So you may need to change the condition to use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if vars{i} &amp;gt; "0" then do;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With those changes, I think that solution would work for what you are asking.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It's a little unusual to read in your A0x variables as character instead of numeric.&amp;nbsp; It can make comparisons trickier.&amp;nbsp; Here, there is no problem since they are all single digits (unless you have non-numeric values that&amp;nbsp;that need to be treated properly.)&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 17:14:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324344#M72000</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-01-12T17:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324345#M72001</link>
      <description>&lt;P&gt;Hey HB, thanks but each chart is assigned to a certain group i.e. medicine, surgery etc. so I want to select on that to get all applicable charts and their HH values.&amp;nbsp; So that is why I want one complete list of all HH values per chart,&amp;nbsp;even if the chart shows up more than once, so I can either run a list on the HH values OR on the group.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With your option I don't have that flexibility.&amp;nbsp; I actually did what you've done but then wanted to merge all together AND create a field of "HH" which is where this thread started.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 17:15:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324345#M72001</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2017-01-12T17:15:07Z</dc:date>
    </item>
    <item>
      <title>Re: Loop Through Multiple Datasets and Create Field based on Dataset Name?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324346#M72002</link>
      <description>&lt;P&gt;Thanks Astounding.&amp;nbsp; Yes&amp;nbsp; the values are 0 or 1 only because either the condition applies or it doesn't but thanks for the heads up in case other values may be in the dataset for future projects.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I changed it a bit based on my last post so that array vars{*} includes other values i.e. a0: b1: c1: ; and any others so that whatever the field is it will be captured.&amp;nbsp; And I changed actual to HH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And it works!&amp;nbsp; Thanks so much to all of you for your persistence.&amp;nbsp; Much, much less code than I was prepared for which is always good.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2017 17:20:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-Through-Multiple-Datasets-and-Create-Field-based-on-Dataset/m-p/324346#M72002</guid>
      <dc:creator>shellp55</dc:creator>
      <dc:date>2017-01-12T17:20:20Z</dc:date>
    </item>
  </channel>
</rss>

