<?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 56 character variable increment counter for variables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656619#M196930</link>
    <description>&lt;P&gt;OP, you can use PROC FREQ on the resulting table to get your counts but the solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;&amp;nbsp;is quite succinct and does what you need efficiently.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jun 2020 23:08:27 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-06-10T23:08:27Z</dc:date>
    <item>
      <title>Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656606#M196919</link>
      <description>&lt;P&gt;Have a couple million records with a string like&lt;BR /&gt;"00 00 01 00 00 01 00 01 00 00 00 00 01 01 00 01 00 00 00 00 01"&lt;/P&gt;&lt;P&gt;"01 00 01 00 00 00 01 00 00 00 00 00 00 01 00 01 00 00 00 00 00"&lt;BR /&gt;String has a length of 56. Positions 2/4/6/8/10, etc are filled with either a 1 or most likely, 0.&lt;BR /&gt;Positions 1/3/5/7/9, etc. are all zeros and don't matter.&lt;BR /&gt;.&lt;BR /&gt;My job is parse the string of each record every two positions&lt;BR /&gt;(there are no spaces, that is just for clarification).&lt;/P&gt;&lt;P&gt;If there is a 1 in position two that means increment var1 +1&lt;BR /&gt;If there is ALSO a 1 in position four, (don't care about leading "0"'s&lt;BR /&gt;in position 1/3/5/9, etc.) increment var2 + 1. Each two positions&lt;BR /&gt;represent a different var, 28 total vars. String length is ALWAYS 56.&lt;/P&gt;&lt;P&gt;The entire 56 len string must be parsed every two characters. Potentially&lt;BR /&gt;there could be 28 variables that have to be incremented in each pass of&lt;BR /&gt;the string, (but not realistic, most likely there is only five or six)&lt;BR /&gt;which could be found in any section of the string, beginning to end&lt;BR /&gt;(as long as they are in position 2/4/6/8 up to 56, etc.)&lt;/P&gt;&lt;P&gt;Using the first example string, results would be&lt;/P&gt;&lt;P&gt;Var1&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;Var2&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;Var3&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;Var4&amp;nbsp; 0&lt;/P&gt;&lt;P&gt;Var5 0&lt;BR /&gt;var6&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;var7&amp;nbsp; 0&lt;BR /&gt;Var8&amp;nbsp; 1&lt;/P&gt;&lt;P&gt;..&lt;BR /&gt;Var13&amp;nbsp; 1&lt;BR /&gt;Var14 1&lt;/P&gt;&lt;P&gt;var15 0&lt;BR /&gt;Var16 1&lt;BR /&gt;Var21 1&amp;nbsp; (skipping a bunch of vars with 0's)&lt;/P&gt;&lt;P&gt;Now we process the second string.&lt;/P&gt;&lt;P&gt;Results are now:&lt;/P&gt;&lt;P&gt;Var1 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var2 0 (still zero, nothing in that position so far).&lt;/P&gt;&lt;P&gt;Var3 1+1 = 2&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var4 0 (still zero)&lt;/P&gt;&lt;P&gt;Var5 0&amp;nbsp;(still zero)&lt;/P&gt;&lt;P&gt;Var6 1 (from previous row)&lt;/P&gt;&lt;P&gt;Var7 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;Var8 0&lt;/P&gt;&lt;P&gt;..&lt;/P&gt;&lt;P&gt;Var14 1&lt;/P&gt;&lt;P&gt;Var15 0&lt;/P&gt;&lt;P&gt;Var 16 1&lt;/P&gt;&lt;P&gt;Var 21 1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what my boss gave me:&lt;BR /&gt;**if substr(BigString,2,1)='1' then var1+1;**&lt;/P&gt;&lt;P&gt;OK. Fine.&lt;BR /&gt;A) There are 27 more places to evaluate in the string.&lt;BR /&gt;B) there are a couple million records.&lt;/P&gt;&lt;P&gt;28 nested if then do loops doesn't sound like an answer (all I could think of). At least not to me.&lt;/P&gt;&lt;P&gt;Cut-and-pasted a lot of looping code as below, which check every two positions ,&lt;/P&gt;&lt;P&gt;but I get a finished product with twice as many records&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;as I started with in a table I can query, but I'm looking to store variables var1-28 to access them later.&lt;/P&gt;&lt;P&gt;(I don't have any choice about this).&lt;BR /&gt;&lt;STRONG&gt;Thanx.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;data have;&lt;BR /&gt;set sources;&lt;BR /&gt;Obs = _n_;&lt;BR /&gt;len = length(sourcerow);&lt;/P&gt;&lt;P&gt;do i=1 to len by 2;&lt;BR /&gt;value = substr(sourcerow, i, 2);&lt;BR /&gt;if value gt '00' then&lt;BR /&gt;output;&amp;nbsp;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 22:31:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656606#M196919</guid>
      <dc:creator>Jumboshrimps</dc:creator>
      <dc:date>2020-06-10T22:31:36Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656617#M196928</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
set sources;
array a{*} var1 -- var28;
Obs = _n_;
len = length(sourcerow);
do i=2 to len by 2;
a[i/2]= input(substr(sourcerow, i, 1));
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 Jun 2020 23:02:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656617#M196928</guid>
      <dc:creator>smantha</dc:creator>
      <dc:date>2020-06-10T23:02:24Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656619#M196930</link>
      <description>&lt;P&gt;OP, you can use PROC FREQ on the resulting table to get your counts but the solution from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;&amp;nbsp;is quite succinct and does what you need efficiently.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 23:08:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656619#M196930</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-06-10T23:08:27Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656622#M196933</link>
      <description>&lt;P&gt;Your shown example string has 62 characters not counting the " characters and only represents 21 "tuples". Intentional, error or what?Or are the spaces not supposed to be in the string? Please provide actual representative data that matches your description. If the string has not spaces then make sure your example has no spaces, if it is 56 characters provide 56 characters.&lt;/P&gt;
&lt;P&gt;Possibly better is provide an actual data set in the form of data step code we can use. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;/&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe you may be skipping things a bit Are there any other variables involved that have to be carried along?&lt;/P&gt;
&lt;P&gt;Your comment of "Potentially there could be 28 variables that have to be incremented in each pass of&lt;BR /&gt;&amp;nbsp;the string, (but not realistic, most likely there is only five or six)" makes it sound like you have blank and not values is that actually case?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then show what the final desired output data set looks like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jun 2020 23:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656622#M196933</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-10T23:22:45Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656886#M196956</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28840"&gt;@Jumboshrimps&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Borrowing code from&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214340"&gt;@smantha&lt;/a&gt;&amp;nbsp;, here is a solution that gives you what you looking for&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data sources;
	sourcerow="00000100000100010000000001010001000000000101010001010001";
	output;
	sourcerow="01000100000001000000000000010001000000000000010001010100";
	output;
run;

data want(KEEP=Var:);
	array a{28} 4 var1-var28;

	do _n_=1 by 1 until(eof);
		set sources end=eof;
		len=length(sourcerow);

		do i=2 to len by 2;
			a[i/2]=sum(a[i/2],input(substr(sourcerow, i, 1),1.));
		end;
	end;
	output;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps,&lt;/P&gt;
&lt;P&gt;Ahmed&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 03:15:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656886#M196956</guid>
      <dc:creator>AhmedAl_Attar</dc:creator>
      <dc:date>2020-06-11T03:15:59Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656978#M196958</link>
      <description>&lt;P&gt;If I understood correctly, like this?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input SOURCEROW $56.;
cards;
11111111111111110000000000000011111111111111111111111111
00000000000000111100000000000011111111111111111111111111
00000000000000001100000000000000000000000000000000000000
run;

data WANT; 
  set HAVE;  
  array VAR[28];
  do I=2 to 56 by 2;
    VAR[I/2]+ input(char(SOURCEROW,I),1.);
  end;
run;

proc print noobs;
  var VAR: ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;&lt;A name="IDX" target="_blank"&gt;&lt;/A&gt;
&lt;TABLE class="systitleandfootercontainer" summary="Page Layout" width="100%" frame="void" rules="none" cellspacing="1" cellpadding="1"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="l systemtitle"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;BR /&gt;
&lt;DIV&gt;
&lt;DIV align="left"&gt;
&lt;TABLE class="table" summary="Procedure Print: Data Set WORK.WANT" frame="box" rules="all" cellspacing="0" cellpadding="5"&gt;&lt;COLGROUP&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt; &lt;COL /&gt;&lt;/COLGROUP&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TH class="r header" scope="col"&gt;VAR1&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR2&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR3&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR4&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR5&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR6&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR7&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR8&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR9&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR10&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR11&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR12&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR13&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR14&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR15&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR16&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR17&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR18&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR19&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR20&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR21&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR22&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR23&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR24&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR25&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR26&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR27&lt;/TH&gt;
&lt;TH class="r header" scope="col"&gt;VAR28&lt;/TH&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;1&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;0&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;TD class="r data"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 04:42:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/656978#M196958</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2020-06-11T04:42:17Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657532#M197036</link>
      <description>&lt;P&gt;Smantha,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanx for your quick reply.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the error log from running the posted code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;56 data have;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;57 set sources;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;58 array a{*} var1 -- var28;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;ERROR: Variable var1 cannot be found on the list of previously defined variables.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;WARNING: Defining an array with zero elements.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;59 Obs = _n_;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;60 len = length(sourcerow);&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;61 do i=2 to len by 2;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;62 a[i/2]= input(substr(sourcerow, i, 1));&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;-&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;22&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;76&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;ERROR 22-322: Syntax error, expecting one of the following: !, !!, &amp;amp;, *, **, +, ',', -, /, &amp;lt;,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&amp;lt;=, &amp;lt;&amp;gt;, =, &amp;gt;, &amp;gt;&amp;lt;, &amp;gt;=, AND, EQ, GE, GT, IN, LE, LT, MAX, MIN, NE, NG, NL, NOT,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;NOTIN, OR, ^, ^=, |, ||, ~, ~=.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;ERROR 76-322: Syntax error, statement will be ignored.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure how to continue.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 14:03:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657532#M197036</guid>
      <dc:creator>Jumboshrimps</dc:creator>
      <dc:date>2020-06-11T14:03:49Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657535#M197039</link>
      <description>That's what I'm talking about!!!!!&lt;BR /&gt;Thanx.</description>
      <pubDate>Thu, 11 Jun 2020 14:10:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657535#M197039</guid>
      <dc:creator>Jumboshrimps</dc:creator>
      <dc:date>2020-06-11T14:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657543#M197044</link>
      <description>&lt;P&gt;Excellent!!&amp;nbsp; Accepted this reply most gratefully.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I look at a couple thousand records, and I see someone(not me, of course!) has entered a number other than "01"&lt;/P&gt;&lt;P&gt;somewhere in the string.&amp;nbsp; We are only counting each non -"00" entry as&amp;nbsp; a 1 for this application.&lt;/P&gt;&lt;P&gt;Is there a similar process I could run &lt;U&gt;before&lt;/U&gt; processing that will loop through every 2 characters and, if not "00", change to&amp;nbsp;"01".&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking through the data, 99% of the values are indeed "01", but I see some "05","09", even some "12" &amp;amp; "14" buried in there.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks so much.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 14:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657543#M197044</guid>
      <dc:creator>Jumboshrimps</dc:creator>
      <dc:date>2020-06-11T14:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657572#M197062</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28840"&gt;@Jumboshrimps&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Excellent!!&amp;nbsp; Accepted this reply most gratefully.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Now I look at a couple thousand records, and I see someone(not me, of course!) has entered a number other than "01"&lt;/P&gt;
&lt;P&gt;somewhere in the string.&amp;nbsp; We are only counting each non -"00" entry as&amp;nbsp; a 1 for this application.&lt;/P&gt;
&lt;P&gt;Is there a similar process I could run &lt;U&gt;before&lt;/U&gt; processing that will loop through every 2 characters and, if not "00", change to&amp;nbsp;"01".&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking through the data, 99% of the values are indeed "01", but I see some "05","09", even some "12" &amp;amp; "14" buried in there.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Try&lt;/P&gt;
&lt;PRE&gt;    VAR[I/2]+ ( input(char(SOURCEROW,I),1.) &amp;gt; 0);&lt;/PRE&gt;
&lt;P&gt;SAS returns 1 for a true comparison and 0 for false. So as long as that "other" character is actually a digit this should work. If you are getting things like A, B, C then the whole approach needs some modification.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 15:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657572#M197062</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-11T15:34:00Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657669#M197117</link>
      <description>&lt;P&gt;You are a genius.&amp;nbsp; I checked each variable row after row, and no row increments more than one from the previous row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 20:25:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657669#M197117</guid>
      <dc:creator>Jumboshrimps</dc:creator>
      <dc:date>2020-06-11T20:25:08Z</dc:date>
    </item>
    <item>
      <title>Re: Loop through 56 character variable increment counter for variables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657672#M197118</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/28840"&gt;@Jumboshrimps&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;You are a genius.&amp;nbsp; I checked each variable row after row, and no row increments more than one from the previous row.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not really, just the recipient of revealed wisdom from a prior boss when I was learning SAS back in 1987. Computers were slower and this sort of comparison to numeric ran faster than IF/Then/Else. I had asked why we had some code that looked something like:&lt;/P&gt;
&lt;PRE&gt;newvar = (a=10)*(a*b*c) + (a=5)*(a*a*b) + (a=1)*(a*b*b);&lt;/PRE&gt;
&lt;P&gt;Which is one way to pick a calculation instead of If a=10 then ...&amp;nbsp; ; else if a=5 then ... ; else if a=1 then ... ;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jun 2020 23:07:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Loop-through-56-character-variable-increment-counter-for/m-p/657672#M197118</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-06-11T23:07:27Z</dc:date>
    </item>
  </channel>
</rss>

