<?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 Arraying variables that have character and numeric codes in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357641#M10737</link>
    <description>&lt;P&gt;Hey guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im trying to array some codes that I have that I need to later merge on. The codes are numeric and sometimes use characters to form the code as well (e.g., 111222, 111A11, 222333, 22B044, 22-B11).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm using is this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data all.matches2;&lt;BR /&gt;set all.matches1;&lt;BR /&gt;array vars{30} match1-match30;&lt;BR /&gt;obs = _n_;&lt;BR /&gt;do i = 1 to 30;&lt;BR /&gt;match = vars{i};&lt;BR /&gt;if not missing(match) then output all.matches2;&lt;BR /&gt;end;&lt;BR /&gt;drop i match1-match30;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I get this error message:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;76 data all.matches2;&lt;BR /&gt;77 set all.matches1;&lt;BR /&gt;78 array vars{30} match1-match30;&lt;BR /&gt;ERROR: All variables in array list must be the same type, i.e., all numeric or character.&lt;BR /&gt;ERROR: All variables in array list must be the same type, i.e., all numeric or character.&lt;BR /&gt;ERROR: All variables in array list must be the same type, i.e., all numeric or character.&lt;BR /&gt;79 obs = _n_;&lt;BR /&gt;80 do i = 1 to 30;&lt;BR /&gt;81 match = vars{i};&lt;BR /&gt;82 if not missing(match) then output all.matches2;&lt;BR /&gt;83 end;&lt;BR /&gt;84 drop i match1-match30;&lt;BR /&gt;85 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set ALL.MATCHES2 may be incomplete. When this step was stopped there were&lt;BR /&gt;0 observations and 11 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.02 seconds&lt;BR /&gt;cpu time 0.03 seconds&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What can I do in order to make my code work?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&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 May 2017 19:17:47 GMT</pubDate>
    <dc:creator>r4321</dc:creator>
    <dc:date>2017-05-10T19:17:47Z</dc:date>
    <item>
      <title>Arraying variables that have character and numeric codes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357641#M10737</link>
      <description>&lt;P&gt;Hey guys,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im trying to array some codes that I have that I need to later merge on. The codes are numeric and sometimes use characters to form the code as well (e.g., 111222, 111A11, 222333, 22B044, 22-B11).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code I'm using is this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data all.matches2;&lt;BR /&gt;set all.matches1;&lt;BR /&gt;array vars{30} match1-match30;&lt;BR /&gt;obs = _n_;&lt;BR /&gt;do i = 1 to 30;&lt;BR /&gt;match = vars{i};&lt;BR /&gt;if not missing(match) then output all.matches2;&lt;BR /&gt;end;&lt;BR /&gt;drop i match1-match30;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I get this error message:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;76 data all.matches2;&lt;BR /&gt;77 set all.matches1;&lt;BR /&gt;78 array vars{30} match1-match30;&lt;BR /&gt;ERROR: All variables in array list must be the same type, i.e., all numeric or character.&lt;BR /&gt;ERROR: All variables in array list must be the same type, i.e., all numeric or character.&lt;BR /&gt;ERROR: All variables in array list must be the same type, i.e., all numeric or character.&lt;BR /&gt;79 obs = _n_;&lt;BR /&gt;80 do i = 1 to 30;&lt;BR /&gt;81 match = vars{i};&lt;BR /&gt;82 if not missing(match) then output all.matches2;&lt;BR /&gt;83 end;&lt;BR /&gt;84 drop i match1-match30;&lt;BR /&gt;85 run;&lt;/P&gt;&lt;P&gt;NOTE: The SAS System stopped processing this step because of errors.&lt;BR /&gt;WARNING: The data set ALL.MATCHES2 may be incomplete. When this step was stopped there were&lt;BR /&gt;0 observations and 11 variables.&lt;BR /&gt;NOTE: DATA statement used (Total process time):&lt;BR /&gt;real time 0.02 seconds&lt;BR /&gt;cpu time 0.03 seconds&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What can I do in order to make my code work?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help.&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 May 2017 19:17:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357641#M10737</guid>
      <dc:creator>r4321</dc:creator>
      <dc:date>2017-05-10T19:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: Arraying variables that have character and numeric codes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357643#M10738</link>
      <description>&lt;P&gt;Add a $ to your array statement:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;array vars{30} $30 match1-match30;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;edited: Sorry ignore mine, Reeza is right, i didn;t look at your program properly&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 19:26:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357643#M10738</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2017-05-10T19:26:22Z</dc:date>
    </item>
    <item>
      <title>Re: Arraying variables that have character and numeric codes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357645#M10739</link>
      <description>&lt;P&gt;They do need to be all the same type as well. If they aren't then you'll need to use multiple arrays OR convert them to the same type.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 19:24:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357645#M10739</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-10T19:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Arraying variables that have character and numeric codes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357657#M10742</link>
      <description>&lt;P&gt;Here's a handy syntax that will let you create two arrays (one for numeric variables, and one for character).&amp;nbsp; This way, you don't need to know which variables are which type:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;array nums {*} match1-numeric-match30;&lt;/P&gt;
&lt;P&gt;array chars {*} match1-character-match30;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then later:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;do i=1 to dim(nums);&amp;nbsp;&amp;nbsp;&amp;nbsp; or&amp;nbsp;&amp;nbsp;&amp;nbsp; do i=1 to dim(chars);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, you still need to figure out what to do from that point.&amp;nbsp; You can't have a single variable named MATCH that is sometimes numeric and sometimes character.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 19:47:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357657#M10742</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-10T19:47:18Z</dc:date>
    </item>
    <item>
      <title>Re: Arraying variables that have character and numeric codes</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357696#M10745</link>
      <description>&lt;P&gt;How can I convert them to the same type? I suppose I want them to all be character variables (even if they = 222111).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 22:09:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Arraying-variables-that-have-character-and-numeric-codes/m-p/357696#M10745</guid>
      <dc:creator>r4321</dc:creator>
      <dc:date>2017-05-10T22:09:54Z</dc:date>
    </item>
  </channel>
</rss>

