<?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: Matching Value Issue in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227704#M41045</link>
    <description>&lt;P&gt;Ah, so you want to change any variable in X OR Y to have an underscore. &amp;nbsp;If so, do it in one go:&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; select &amp;nbsp;distinct cats(VARIABLE,'=',VARIABLE,'_') &lt;BR /&gt;&amp;nbsp; into &amp;nbsp; &amp;nbsp; :LIST separated by ' '&lt;BR /&gt;&amp;nbsp; from &amp;nbsp; &amp;nbsp;(select VARIABLE from X union all select VARIABLE from Y);&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;proc datasets library=work nodetails nolist;&lt;BR /&gt;&amp;nbsp; modify table;&lt;BR /&gt;&amp;nbsp; rename &amp;amp;list.;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above puts X and Y together in the subquery, then from that combined data selects a distinct list of variables to rename, which is then used in the rename.&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2015 15:58:21 GMT</pubDate>
    <dc:creator>RW9</dc:creator>
    <dc:date>2015-09-29T15:58:21Z</dc:date>
    <item>
      <title>Matching Value Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227635#M41031</link>
      <description>&lt;P&gt;I have to tables below as X and Y. X table has Q columns which passed several conditions.And Y table contains the Q columns that i want to change. If there are same Q columns on both the tables i receive an error. How can i resolve this problem ? For example I receive an error if both of the tables contain Q1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data table;
length ID $ 7 Q1 8 Q2 8 Q3 8 Q4 8 Q5 8 Q6 8;
infile datalines missover dlm=",";
input ID Q1 Q2 Q3 Q4 Q5 Q6 ;
datalines;
RefID1,0.90,0.80,0.00,0.90,0.00,0.70
RefID2,0.100,0.100,0.00,0.70,0.00,60
RefID3,0.40,0.80,0.00,0.90,0.00,0.50
RefID4,0.55,0.80,0.05,0.90,0.00,0.69
RefID5,0.00,0.80,0.60,0.90,0.20,0.90
RefID6,0.96,0.00,0.40,0.90,0.00,0.95
RefID7,0.00,0.80,0.90,0.90,0.00,0.99
RefID8,0.56,0.80,0.55,0.90,0.00,0.93
RefID9,0.99,0.80,0.99,0.90,0.00,0.70
RefID10,0.89,0.88,0.56,0.90,0.00,0.00
;
run;
data x;
input variable $ percentage;
cards;
Q1 0.9
Q2 0.8
Q4 0.2
Q6 0.5
;
run;
 
data y;
input variable $;
cards;
Q1
Q3
;
proc sql;
select cats(variable,'=',variable,'_') into : list separated by ' '
  from x;
quit;
proc datasets library=work nodetails nolist;
modify table;
rename &amp;amp;list ;
quit;
proc sql;
select cats(variable,'=',variable,'_') into : list2 separated by ' '
  from y;
quit;
proc datasets library=work nodetails nolist;
modify table;
rename &amp;amp;list2 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2015 12:07:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227635#M41031</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-29T12:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Matching Value Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227644#M41034</link>
      <description>&lt;P&gt;The reason your code is not working is that in the first datasets step you are renaming all the variables in TABLE which appear in X to have an underscore, so after the first datasets TABLE looks like this:&lt;/P&gt;&lt;P&gt;ID Q1_ Q2_ Q3 Q4_ Q5 Q6_;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You next datasets step is trying to find Q1 and Q3 in that TABLE, which don't exist. &amp;nbsp;Now you could change your second proc sql to try to pick up on this, i.e. if value appears in dataset with _ etc. &amp;nbsp;however that starts to become quite complicated. &amp;nbsp;My quesiton is this, why are you doing this, what is it your trying to achieve? &amp;nbsp; I would change the operation (if I did it this way in the first place) to:&lt;/P&gt;&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; delete from X&lt;BR /&gt;&amp;nbsp; where VARIABLE not in (select VARIABLE from Y);&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;This then means X contains all the variables to run your check or whatever on. &amp;nbsp;No need to be renaming variables and creating lists etc.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 12:35:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227644#M41034</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-29T12:35:27Z</dc:date>
    </item>
    <item>
      <title>Re: Matching Value Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227682#M41040</link>
      <description>&lt;P&gt;&lt;SPAN style="font: 12.8px/normal arial, sans-serif; color: rgb(34, 34, 34); text-transform: none; text-indent: 0px; letter-spacing: normal; word-spacing: 0px; float: none; display: inline !important; white-space: normal; widows: 1; font-size-adjust: none; font-stretch: normal; background-color: rgb(255, 255, 255); -webkit-text-stroke-width: 0px;"&gt;Thank you. This is how I get the results I want. If you have a better idea, I will be happy to apply. Otherwise, I will consider your response as the right way. These are the tasks assigned to me so I am trying to apply &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
  delete from X
  where VARIABLE in (select VARIABLE from Y);
quit;

proc sql;
 select cats(variable,'=',variable,'_') into : list separated by ' '
  from x;
quit;
proc datasets library=work nodetails nolist;
 modify table;
 rename &amp;amp;list ;
quit;

proc sql;
 select cats(variable,'=',variable,'_') into : list2 separated by ' '
  from y;
quit;
proc datasets library=work nodetails nolist;
 modify table;
 rename &amp;amp;list2 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2015 15:10:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227682#M41040</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-29T15:10:52Z</dc:date>
    </item>
    <item>
      <title>Re: Matching Value Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227704#M41045</link>
      <description>&lt;P&gt;Ah, so you want to change any variable in X OR Y to have an underscore. &amp;nbsp;If so, do it in one go:&lt;/P&gt;
&lt;P&gt;proc sql;&lt;BR /&gt;&amp;nbsp; select &amp;nbsp;distinct cats(VARIABLE,'=',VARIABLE,'_') &lt;BR /&gt;&amp;nbsp; into &amp;nbsp; &amp;nbsp; :LIST separated by ' '&lt;BR /&gt;&amp;nbsp; from &amp;nbsp; &amp;nbsp;(select VARIABLE from X union all select VARIABLE from Y);&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;proc datasets library=work nodetails nolist;&lt;BR /&gt;&amp;nbsp; modify table;&lt;BR /&gt;&amp;nbsp; rename &amp;amp;list.;&lt;BR /&gt;quit;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The above puts X and Y together in the subquery, then from that combined data selects a distinct list of variables to rename, which is then used in the rename.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 15:58:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227704#M41045</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-09-29T15:58:21Z</dc:date>
    </item>
    <item>
      <title>Re: Matching Value Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227726#M41055</link>
      <description>&lt;P&gt;Hi, how about reducing the number of steps (UNION purges duplicate rows by default) ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;proc sql noprint;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;select cats(variable,'=',variable,'_') into :list separated by ' ' from&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;(select variable from x&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;union&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;select variable from y);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;proc datasets library=work nodetails nolist;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;modify table;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;rename &amp;amp;list ;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ps ... modified data step (less code, numeric length defaults to &lt;span class="lia-unicode-emoji" title=":smiling_face_with_sunglasses:"&gt;😎&lt;/span&gt; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;data table;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;infile datalines dsd;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;input ID :$7. Q1-Q6;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;datalines;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID1,0.90,0.80,0.00,0.90,0.00,0.70&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID2,0.100,0.100,0.00,0.70,0.00,60&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID3,0.40,0.80,0.00,0.90,0.00,0.50&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID4,0.55,0.80,0.05,0.90,0.00,0.69&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID5,0.00,0.80,0.60,0.90,0.20,0.90&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID6,0.96,0.00,0.40,0.90,0.00,0.95&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID7,0.00,0.80,0.90,0.90,0.00,0.99&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID8,0.56,0.80,0.55,0.90,0.00,0.93&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID9,0.99,0.80,0.99,0.90,0.00,0.70&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;RefID10,0.89,0.88,0.56,0.90,0.00,0.00&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 17:47:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227726#M41055</guid>
      <dc:creator>MikeZdeb</dc:creator>
      <dc:date>2015-09-29T17:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Matching Value Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227782#M41076</link>
      <description>&lt;P&gt;Thank you the code worked &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 22:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227782#M41076</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-29T22:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: Matching Value Issue</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227784#M41077</link>
      <description>&lt;P&gt;Thanks a lot. It is working &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2015 22:40:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Matching-Value-Issue/m-p/227784#M41077</guid>
      <dc:creator>turcay</dc:creator>
      <dc:date>2015-09-29T22:40:47Z</dc:date>
    </item>
  </channel>
</rss>

