<?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: efficiently change variable values selectively? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94346#M19891</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haikuo:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the head's up.&amp;nbsp; Oversight corrected.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Aug 2012 21:03:28 GMT</pubDate>
    <dc:creator>mkeintz</dc:creator>
    <dc:date>2012-08-15T21:03:28Z</dc:date>
    <item>
      <title>efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94326#M19871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P id="yui_3_2_0_1_1345022163832271"&gt;&lt;SPAN id="yui_3_2_0_1_1345022163832270"&gt;How do I dynamically rename/update the port_id in port data&lt;VAR id="yiv796808881yui-ie-cursor"&gt;&lt;/VAR&gt;, based on the bench data, any port data is prefixed with p, bench with b.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;port data has about 10k rows while bench has less than 30 rows.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG style="color: navy; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt; port;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt; port_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;33&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;33&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;33&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;STRONG style="color: navy; font-size: 10.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt; bench;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;input&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;port bench;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: blue;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;10 33&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New';"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;/*make data like this&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;p_10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;p_10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;p_10&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;b_33&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;b_33&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;b-33&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="margin-bottom: 0.0001pt;"&gt;&lt;SPAN style="font-size: 10.0pt; font-family: 'Courier New'; color: green;"&gt;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 09:28:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94326#M19871</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-08-15T09:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94327#M19872</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Instead of actually changing the values you could simply create a format and then apply this format on port_id as done in code below using the data you've posted:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data Vprep /view=Vprep;&lt;BR /&gt;&amp;nbsp; set bench;&lt;BR /&gt;&amp;nbsp; retain fmtname 'port_id';&lt;BR /&gt;&amp;nbsp; length label $ 20;&lt;BR /&gt;&amp;nbsp; start=port;&amp;nbsp; label=cats('p_',port);&amp;nbsp; output;&lt;BR /&gt;&amp;nbsp; start=bench; label=cats('b_',bench); output;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format cntlin=Vprep;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc datasets lib=work nolist;&lt;BR /&gt;&amp;nbsp; modify port;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; format port_id port_id.;&lt;BR /&gt;&amp;nbsp; run;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you really need the physical values then once you've created the format just add below data step:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data port;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set port;&lt;/P&gt;&lt;P&gt;&amp;nbsp; newvar=put(port_id,port_id.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 10:13:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94327#M19872</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-08-15T10:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94328#M19873</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Under the assumption that your 'port' and your 'bench' are mutually exclusive, the following Hash() approach seems working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data port;&lt;/P&gt;&lt;P&gt;input port_id;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;10&lt;/P&gt;&lt;P&gt;33&lt;/P&gt;&lt;P&gt;33&lt;/P&gt;&lt;P&gt;33&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data bench;&lt;/P&gt;&lt;P&gt;input&lt;/P&gt;&lt;P&gt;port bench;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;10 33&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if 0 then set port;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dcl hash h(dataset: 'port', multidata:'y');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.definekey('port_id');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.definedata('port_id');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; h.definedone();&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set bench;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do rc=h.find(key:port) by 0 while (rc=0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_id=cats('p_',port_id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc=h.find_next(key:port);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; do rc=h.find(key:bench) by 0 while (rc=0);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; new_id=cats('b_',port_id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rc=h.find_next(key:bench);&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; keep port_id new_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 12:44:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94328#M19873</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-15T12:44:02Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94329#M19874</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;They are NOT mutual exclusive, that is the reason I have to prefix it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, how do I do that to loose that assumption?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 14:45:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94329#M19874</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-08-15T14:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94330#M19875</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I really need to change the value, NOT format them.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 14:46:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94330#M19875</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-08-15T14:46:25Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94331#M19876</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data port;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input port_id @@;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;cards;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;10 10 10 33 33 33&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data bench;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input port bench;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;cards;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;10 33&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data new (keep=port_id newvar);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;set bench;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;array pb(*) _numeric_;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;do until(done);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; set port end=done;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; newvar = catx('_',char(vname(pb(whichn(port_id, of pb(*)))),1),port_id);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;port_id&amp;nbsp;&amp;nbsp;&amp;nbsp; newvar&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_10&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_10&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_10&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; 33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b_33&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; 33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b_33&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; 33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b_33&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 15:00:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94331#M19876</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-08-15T15:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94332#M19877</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If they are not mutually exclusive then how do you know if eg. Port_ID =40 is "Port" or "Bench" - and if it can be both: Do you have some rule or additional attributes to decide what to choose?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 15:02:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94332#M19877</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-08-15T15:02:39Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94333#M19878</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Let me clarify a little bit further, the true issue is in port data, 33 belongs to both port_id and bench_id.&lt;/P&gt;&lt;P&gt;But the rule is: look at bench data, if we find the data in bench_id, we prefix it as "b_", all others are named "p_"&lt;/P&gt;&lt;P&gt;Because 33 in bench data appeared in bench_id, we name it "b_33", rather than p_33, but 10 is not appearing in bench_id, so it is prefixed as p_10.&lt;/P&gt;&lt;P&gt;At the same time dimensions for port data is 10k rows over 50 vars, while bench has less than 30 rows and 10 vars, I need a efficient way to prefix this variable.&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 11.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; port;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; port_id @@;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;10 10 10 33 33&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 11.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; bench;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; port_id bench_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;10 33&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;33 44&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;/*result i want:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;p_10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;P_10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;p_10&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;b_33&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;b_33&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: green; background: white;"&gt;*/&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 15:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94333#M19878</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-08-15T15:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94334#M19879</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the bench data is, variable is not port, bench, sorry about that, I test your code, it doesn't look like working&lt;/P&gt;&lt;P&gt;&lt;STRONG style="color: navy; background: white; font-size: 11.0pt; font-family: 'Courier New';"&gt;data&lt;/STRONG&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; bench;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;input&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt; port_id bench_id;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: blue; background: white;"&gt;cards&lt;/SPAN&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;10 33&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: #FFFFC0;"&gt;33 44&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 11.0pt; font-family: 'Courier New'; color: black; background: white;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 15:24:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94334#M19879</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-08-15T15:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94335#M19880</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Given that you have a very small number of bench_id values, this approach should be tried as well:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sql noprint;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; select distinct bench_id into : bench_list separated by ',' from bench;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; set port;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if port_id in (&amp;amp;bench_list) then prefix='b_';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else prefix='p_';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; newvar = prefix || put(port_id, z2.);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 15:31:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94335#M19880</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2012-08-15T15:31:55Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94336#M19881</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"At the same time dimensions for port data is 10k rows over 50 vars, while bench has less than 30 rows and 10 vars"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please provide sample data which better reflects how your real data structure looks like? That would help a lot to come up with an appropriate solution.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 15:33:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94336#M19881</guid>
      <dc:creator>Patrick</dc:creator>
      <dc:date>2012-08-15T15:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94337#M19882</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi ... if all you have to do is first look at all the values of BENCH_ID in order to make a decision ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data port;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input port_id @@;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;cards;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;10 10 10 33 33 33 44 55 33 10 44&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data bench;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;input port_id bench_id;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;cards;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;10 33&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;33 44&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;data new (keep=port_id newvar);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;length its_a_bench $100;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;do j=1 by 1 until (done1);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; set bench (keep=bench_id) end=done1;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp; its_a_bench = catx('/', its_a_bench , bench_id);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;do until(done2);&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; set port end=done2;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; newvar = ifc(find(its_a_bench,catt(port_id)) , catt('b_',port_id) , catt('p_',port_id));&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; output;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;end;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;port_id&amp;nbsp;&amp;nbsp;&amp;nbsp; newvar&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_10&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_10&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_10&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b_33&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b_33&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b_33&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 44&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b_44&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 55&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_55&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 33&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b_33&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p_10&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp; 44&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b_44&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 15:37:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94337#M19882</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-08-15T15:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94338#M19883</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Really appreciate this great discussion.&lt;/P&gt;&lt;P&gt;I think astounding's code is much simpler and worked. &lt;/P&gt;&lt;P&gt;MikeZdeb's code also worked, but personally I don't want to use the looping, I think it could cause the performance issue potentially when processing large volume data.&lt;SPAN class="j-post-author "&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="j-post-author "&gt;I may test the efficiency and hardware resources to compare further.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 16:08:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94338#M19883</guid>
      <dc:creator>ZRick</dc:creator>
      <dc:date>2012-08-15T16:08:43Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94339#M19884</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Talking about 'efficiently',&amp;nbsp; there still is a Hash() approach, which does enforce the new rule:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data port;&lt;/P&gt;&lt;P&gt;input port_id @@;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;10 10 10 33 33&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data bench;&lt;/P&gt;&lt;P&gt;input port_id bench_id;&lt;/P&gt;&lt;P&gt;cards;&lt;/P&gt;&lt;P&gt;10 33&lt;/P&gt;&lt;P&gt;33 44&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then do;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if 0 then set bench;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dcl hash b(dataset: 'bench(keep=bench_id)');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.definekey('bench_id');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; b.definedone();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dcl hash p(dataset: 'bench(keep=port_id)');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p.definekey('port_id');&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; p.definedone();&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set port;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; if b.check(key:port_id)=0 then&amp;nbsp; new_id=cats('b_',port_id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else if p.check(key:port_id)=0 then new_id=cats('p_',port_id);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; else new_id=cats(port_id);&lt;/P&gt;&lt;P&gt;&amp;nbsp; keep port_id new_id;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; proc print;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 18:08:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94339#M19884</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-15T18:08:03Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94340#M19885</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Haikuo:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Data set PORT does not have a variable named BENCH, so&amp;nbsp; bench is always missing, and b.check() will never be 0.&amp;nbsp; No new_id's will be "b".&amp;nbsp; Do you mean&amp;nbsp; b.check(key:port_id)?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 18:37:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94340#M19885</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-15T18:37:12Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94341#M19886</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Good Catch, Mark. UPDATING...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 18:43:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94341#M19886</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-15T18:43:19Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94342#M19887</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ... the "looping" you refer to is to just read the data sets.&amp;nbsp; Astounding's code read the data sets first in SQL, then using the implied looping of the data step rather than&amp;nbsp; DO/SET/END as I did.&amp;nbsp; So, just because you don't see "DO" in Astounding's code doesn't mean that loops are not being used, yes/no?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 18:44:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94342#M19887</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2012-08-15T18:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94343#M19888</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I concur, Mike. There is always implicit loop in data step, DOW does not add in one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 18:50:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94343#M19888</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-15T18:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94344#M19889</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I understand the task to be to creating a new id in which the prefix is always a "P" except when port_id matches any existing bench_id, right?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If so, and port_id can be any integer between 1 and (say) 1000, then the simplest approach is to use a "key lookup" technique (i.e. an array in the example below):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;%let max_port=1000;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array letr {&amp;amp;max_port} $1 _temporary_ (&amp;amp;max_port * 'P');&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then do until (end_of_bench);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set bench&amp;nbsp; end=end_of_bench;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; letr{bench_id}='B';&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set port;&lt;/P&gt;&lt;P&gt;&amp;nbsp; new_id=cats(letr{port_id},port_id);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If instead it is to prefix 'P' only when port_id is in the list of ports in BENCH, 'B' when it's in the bench list, and otherwise no prefix, (I saw examples of this) then it's a minor change:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data want;&lt;/P&gt;&lt;P&gt;&amp;nbsp; array letr {&amp;amp;max_port} $1 _temporary_;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; if _n_=1 then do until (end_of_bench);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; set bench end=end_of_bench;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; letr{port_id}='P';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; letr{bench_id}='B';&lt;/P&gt;&lt;P&gt;&amp;nbsp; end;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; set port;&lt;/P&gt;&lt;P&gt;&amp;nbsp; new_id=cats(letr{port_id},port_id);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 19:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94344#M19889</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2012-08-15T19:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: efficiently change variable values selectively?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94345#M19890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Nice trick, Mark! I like it, I remember seeing it from your post @SAS-L. And I assume you forgot putting in 'end=end_of_bench' in your first data step &lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Haikuo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Aug 2012 19:17:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/efficiently-change-variable-values-selectively/m-p/94345#M19890</guid>
      <dc:creator>Haikuo</dc:creator>
      <dc:date>2012-08-15T19:17:54Z</dc:date>
    </item>
  </channel>
</rss>

