<?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: Help with compare variable1 value with numeric part of name of variable2 in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-compare-variable1-value-with-numeric-part-of-name-of/m-p/213250#M267526</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not create an ARRAY and use window as the subscript?&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; window code1 code2 code11;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;datalines&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;2 2 1 3&lt;BR /&gt;3 3 3 4&lt;BR /&gt;1 4 5 6&lt;BR /&gt;4 6 7 8&lt;BR /&gt;2 8 6 3&lt;BR /&gt;6 9 5 7&lt;BR /&gt;7 1 4 5&lt;BR /&gt;11 4 5 6&lt;BR /&gt;10 5 6 7&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; window;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; window code1--code11 value;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; code[&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;11&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;];&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; value = code[window];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;IMG alt="Capture.PNG" class="jive-image" src="https://communities.sas.com/legacyfs/online/11271_Capture.PNG" /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 29 Jul 2015 12:30:21 GMT</pubDate>
    <dc:creator>data_null__</dc:creator>
    <dc:date>2015-07-29T12:30:21Z</dc:date>
    <item>
      <title>Help with compare variable1 value with numeric part of name of variable2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-compare-variable1-value-with-numeric-part-of-name-of/m-p/213248#M267524</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I have the following data with Window and code1 code2... code100 variables.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;For a given record, I compare the value in Window variable with the numerical part (the last 1 or 2 character) of the name of code&lt;I&gt;. If they are the same the new Value variable will be equal to the value of that code.&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Basically it should be like:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; if window&amp;lt;=9 and window=last 1&amp;nbsp; character of variable (code1) then value=code1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;else if window&amp;lt;=9 and window=last 1 character of variable (code2) then value=code2&lt;/P&gt;&lt;P&gt;else if window&amp;gt;9&amp;nbsp; and window=last 2 character of variable (code11) then value=code11; *for 2 digit number;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the value should be like:&lt;/P&gt;&lt;P&gt;1&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;4&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;6&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please help me with that?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HHC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data have;&lt;/P&gt;&lt;P&gt;input window code1 code2 code11;&lt;/P&gt;&lt;P&gt;datalines;&lt;/P&gt;&lt;P&gt;2 2 1 3&lt;/P&gt;&lt;P&gt;3 3 3 4&lt;/P&gt;&lt;P&gt;1 4 5 6&lt;/P&gt;&lt;P&gt;4 6 7 8&lt;/P&gt;&lt;P&gt;2 8 6 3&lt;/P&gt;&lt;P&gt;6 9 5 7&lt;/P&gt;&lt;P&gt;7 1 4 5&lt;/P&gt;&lt;P&gt;11 4 5 6&lt;/P&gt;&lt;P&gt;10 5 6 7&lt;/P&gt;&lt;P&gt;;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 11:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-compare-variable1-value-with-numeric-part-of-name-of/m-p/213248#M267524</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2015-07-29T11:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Help with compare variable1 value with numeric part of name of variable2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-compare-variable1-value-with-numeric-part-of-name-of/m-p/213249#M267525</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The more I think about it the less I like it.&amp;nbsp; What is code, how did it get onto the data?&amp;nbsp; Why does the precision change for variables &amp;gt; 9?&amp;nbsp; Why does code and window not match one-one?&amp;nbsp;&amp;nbsp; Too many questions really.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Well,&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set have;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if window &amp;lt;= 9 and window=input(substr(strip(reverse(put(code1,best.))),1,1),best.) then value=code1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; else if window &amp;lt;= 9 and window=input(substr(strip(reverse(put(code2,best.))),1,1),best.) then value=code1;&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 11:56:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-compare-variable1-value-with-numeric-part-of-name-of/m-p/213249#M267525</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-07-29T11:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: Help with compare variable1 value with numeric part of name of variable2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-compare-variable1-value-with-numeric-part-of-name-of/m-p/213250#M267526</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not create an ARRAY and use window as the subscript?&lt;/P&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; window code1 code2 code11;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;datalines&lt;/SPAN&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffc0;"&gt;2 2 1 3&lt;BR /&gt;3 3 3 4&lt;BR /&gt;1 4 5 6&lt;BR /&gt;4 6 7 8&lt;BR /&gt;2 8 6 3&lt;BR /&gt;6 9 5 7&lt;BR /&gt;7 1 4 5&lt;BR /&gt;11 4 5 6&lt;BR /&gt;10 5 6 7&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;;;;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;data&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; window;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;set&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; have;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;keep&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; window code1--code11 value;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; background-color: #ffffff;"&gt;array&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt; code[&lt;/SPAN&gt;&lt;STRONG style="color: #008080; background-color: #ffffff;"&gt;11&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;];&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&amp;nbsp;&amp;nbsp; value = code[window];&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;proc&lt;/STRONG&gt; &lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;print&lt;/STRONG&gt;; &lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;STRONG style="color: #000080; background-color: #ffffff;"&gt;run&lt;/STRONG&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="font-family: Courier New; font-size: 11pt;"&gt;&lt;SPAN style="color: #000000; background-color: #ffffff;"&gt;&lt;IMG alt="Capture.PNG" class="jive-image" src="https://communities.sas.com/legacyfs/online/11271_Capture.PNG" /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 12:30:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-compare-variable1-value-with-numeric-part-of-name-of/m-p/213250#M267526</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2015-07-29T12:30:21Z</dc:date>
    </item>
    <item>
      <title>Re: Help with compare variable1 value with numeric part of name of variable2</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-compare-variable1-value-with-numeric-part-of-name-of/m-p/213251#M267527</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you, Data_Null,&lt;/P&gt;&lt;P&gt;It work perfectly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Jul 2015 15:43:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-compare-variable1-value-with-numeric-part-of-name-of/m-p/213251#M267527</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2015-07-29T15:43:41Z</dc:date>
    </item>
  </channel>
</rss>

