<?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: Operate on Every Other Column or Use Array with Mixed Data Types? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Operate-on-Every-Other-Column-or-Use-Array-with-Mixed-Data-Types/m-p/355027#M83138</link>
    <description>&lt;P&gt;While ballardw has the right idea, you might find it easier to think about it&amp;nbsp;in this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i=1 to dim(c);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; n(i) = ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; c(i) = .....;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could process each pair (one numeric, one character) in the same iteration of the DO loop.&lt;/P&gt;</description>
    <pubDate>Mon, 01 May 2017 19:01:23 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2017-05-01T19:01:23Z</dc:date>
    <item>
      <title>Operate on Every Other Column or Use Array with Mixed Data Types?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Operate-on-Every-Other-Column-or-Use-Array-with-Mixed-Data-Types/m-p/355000#M83127</link>
      <description>&lt;P&gt;Does anyone know if it's possible to either operate on every other column of a dataset or (preferably) load mixed data types into an array (even possibly a multidimensional one, if needed) in SAS?&amp;nbsp; I have a huge dataset where the columns alternate between numeric and character and I need to operate&amp;nbsp;identically on all the columns, regardless of type. Of course, I can do this easily by outputting the numeric columns to one dataset and the character to another, but given the size of these datasets, I am not thrilled with this solution since I would have to iterate over the dataset at least three times, and I'd rather just make one pass through the data.&amp;nbsp; I suppose I could also do something like this in IML, but I'd prefer to stick with base SAS.&amp;nbsp; I'm consdiering switching to R and this might be the nail in the coffin if I can't find a workable solution in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tried to do something likes this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.temp;
set work.temp;
array myarray {*} $ Char_Q2 Numeric_Q3;
do i=1 to 4 by 2;
/*    operations would go here here */
end;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but, this throws the error:&lt;/P&gt;
&lt;PRE&gt;ERROR: All variables in array list must be the same type, i.e., all numeric or character.&lt;/PRE&gt;
&lt;P&gt;Any ideas?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 18:05:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Operate-on-Every-Other-Column-or-Use-Array-with-Mixed-Data-Types/m-p/355000#M83127</guid>
      <dc:creator>statistician13</dc:creator>
      <dc:date>2017-05-01T18:05:01Z</dc:date>
    </item>
    <item>
      <title>Re: Operate on Every Other Column or Use Array with Mixed Data Types?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Operate-on-Every-Other-Column-or-Use-Array-with-Mixed-Data-Types/m-p/355022#M83136</link>
      <description>&lt;P&gt;Array cannot contain mixed type, either all numeric or all character.&lt;/P&gt;
&lt;P&gt;Since the variables are of different types please describe the operation "I need to operate&amp;nbsp;identically on all the columns". Since very few SAS functions or operations work on both data types a example of what you are actually attempting will help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are TWO special variable lists that could create separate character and numeric arrays, namely _character_ and _numeric_.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Array c (*) _character_;&lt;/P&gt;
&lt;P&gt;Array n (*) _numeric_;&lt;/P&gt;
&lt;P&gt;would declare the arrays.&lt;/P&gt;
&lt;P&gt;Then you could loop over each array separately:&lt;/P&gt;
&lt;P&gt;Do i = 1 to dim(c);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;what ever op&amp;gt;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;do i=1 to dim(n);&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;lt;what ever op&amp;gt;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which would at least be possibly feasible as the functions or operations could be specified to match the the variable type.&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 18:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Operate-on-Every-Other-Column-or-Use-Array-with-Mixed-Data-Types/m-p/355022#M83136</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-05-01T18:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Operate on Every Other Column or Use Array with Mixed Data Types?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Operate-on-Every-Other-Column-or-Use-Array-with-Mixed-Data-Types/m-p/355027#M83138</link>
      <description>&lt;P&gt;While ballardw has the right idea, you might find it easier to think about it&amp;nbsp;in this way:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i=1 to dim(c);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; n(i) = ....;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; c(i) = .....;&lt;/P&gt;
&lt;P&gt;end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could process each pair (one numeric, one character) in the same iteration of the DO loop.&lt;/P&gt;</description>
      <pubDate>Mon, 01 May 2017 19:01:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Operate-on-Every-Other-Column-or-Use-Array-with-Mixed-Data-Types/m-p/355027#M83138</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-01T19:01:23Z</dc:date>
    </item>
  </channel>
</rss>

