<?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 Selection of variables using x1-x5, but with strings in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Selection-of-variables-using-x1-x5-but-with-strings/m-p/417720#M280388</link>
    <description>&lt;P&gt;hi! Ive ran into a problem where i need to create a range of values, contained in strings. The data given is on the format&lt;/P&gt;&lt;P&gt;X-H-237&amp;nbsp; &amp;nbsp;to X-H-240&amp;nbsp; (in reality its a lot more values, but for simplicity lets settle with 237-240).&lt;/P&gt;&lt;P&gt;Is there a function or similar that can handle this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a&amp;nbsp;script showing what i want to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Matrix(drop= i);&lt;BR /&gt;array A(*) A1-A7;&lt;BR /&gt;do i=1 to 7;&lt;BR /&gt;A(i)=rand('Uniform');&lt;BR /&gt;end;&lt;BR /&gt;format B $10.;&lt;BR /&gt;&lt;BR /&gt;input B $;&lt;BR /&gt;datalines;&lt;BR /&gt;X-H-237&lt;BR /&gt;X-H-238&lt;BR /&gt;X-H-239&lt;BR /&gt;X-H-240&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data test;&lt;BR /&gt;/*State 1-5 Rk-states, 6=Delinquent 7=default */&lt;BR /&gt;set Matrix;&lt;BR /&gt;if B in "X-H-237"--"X-H-240" then put A1;&lt;BR /&gt;if B in "X-H-237"-"X-H-240" then put A2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Dec 2017 11:08:45 GMT</pubDate>
    <dc:creator>Shawnty</dc:creator>
    <dc:date>2017-12-01T11:08:45Z</dc:date>
    <item>
      <title>Selection of variables using x1-x5, but with strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selection-of-variables-using-x1-x5-but-with-strings/m-p/417720#M280388</link>
      <description>&lt;P&gt;hi! Ive ran into a problem where i need to create a range of values, contained in strings. The data given is on the format&lt;/P&gt;&lt;P&gt;X-H-237&amp;nbsp; &amp;nbsp;to X-H-240&amp;nbsp; (in reality its a lot more values, but for simplicity lets settle with 237-240).&lt;/P&gt;&lt;P&gt;Is there a function or similar that can handle this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a&amp;nbsp;script showing what i want to do.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data Matrix(drop= i);&lt;BR /&gt;array A(*) A1-A7;&lt;BR /&gt;do i=1 to 7;&lt;BR /&gt;A(i)=rand('Uniform');&lt;BR /&gt;end;&lt;BR /&gt;format B $10.;&lt;BR /&gt;&lt;BR /&gt;input B $;&lt;BR /&gt;datalines;&lt;BR /&gt;X-H-237&lt;BR /&gt;X-H-238&lt;BR /&gt;X-H-239&lt;BR /&gt;X-H-240&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;data test;&lt;BR /&gt;/*State 1-5 Rk-states, 6=Delinquent 7=default */&lt;BR /&gt;set Matrix;&lt;BR /&gt;if B in "X-H-237"--"X-H-240" then put A1;&lt;BR /&gt;if B in "X-H-237"-"X-H-240" then put A2;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 11:08:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selection-of-variables-using-x1-x5-but-with-strings/m-p/417720#M280388</guid>
      <dc:creator>Shawnty</dc:creator>
      <dc:date>2017-12-01T11:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Selection of variables using x1-x5, but with strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selection-of-variables-using-x1-x5-but-with-strings/m-p/417724#M280389</link>
      <description>&lt;P&gt;There really is no need to code all in mixed case, its very hard to read.&amp;nbsp; Now, you can simply change you code to number and use that, thus:&lt;/P&gt;
&lt;PRE&gt;data matrix(drop= i);
  array a(*) a1-a7;
  do i=1 to 7;
    a(i)=rand('uniform');
  end;
  format b $10.;
  input b $;
datalines;
X-H-237
X-H-238
X-H-239
X-H-240
;
run;

data test;
  set matrix;
  if 237 &amp;lt;= input(scan(b,3,"-"),best.) &amp;lt;= 240 then put a1;
run;&lt;/PRE&gt;
&lt;P&gt;(you will note the use of the code window to preserve indenting).&amp;nbsp; With that you can do numeric ranges, although I do not know what the second datastep is meant to acheive?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Dec 2017 11:27:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selection-of-variables-using-x1-x5-but-with-strings/m-p/417724#M280389</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-12-01T11:27:49Z</dc:date>
    </item>
    <item>
      <title>Re: Selection of variables using x1-x5, but with strings</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Selection-of-variables-using-x1-x5-but-with-strings/m-p/417726#M280390</link>
      <description>Hi RW9, Exactly what i was looking for. Thank you!&lt;BR /&gt;&lt;BR /&gt;Second datastep was just created to illustrate the if statement. What happends in it was irrelevant for the question so i left it out.</description>
      <pubDate>Fri, 01 Dec 2017 11:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Selection-of-variables-using-x1-x5-but-with-strings/m-p/417726#M280390</guid>
      <dc:creator>Shawnty</dc:creator>
      <dc:date>2017-12-01T11:38:56Z</dc:date>
    </item>
  </channel>
</rss>

