<?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 how to apply variable values in other table. in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449249#M113043</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a table called erased. It has only one column(100000 obs), based on those values ,I need to change the values in other table.(I have a macro to change the values) but need to apply the logic.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Erased;
set lib.Erased(keep=id);
run;

proc sql noprint;
	select count(*) into :numb_ids
	from Erased;
	;
quit;

data names;
	set names;
	%all(name);/*this macro is changing the varibale vales in names table*/ /*but my condition should be if the values meets from the erased table then change the values in name table elase don't change*/
run;

/*this logic need to apply for the all the tables in all libraries*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;SS&lt;/P&gt;</description>
    <pubDate>Wed, 28 Mar 2018 09:21:23 GMT</pubDate>
    <dc:creator>sathya66</dc:creator>
    <dc:date>2018-03-28T09:21:23Z</dc:date>
    <item>
      <title>how to apply variable values in other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449249#M113043</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a table called erased. It has only one column(100000 obs), based on those values ,I need to change the values in other table.(I have a macro to change the values) but need to apply the logic.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Erased;
set lib.Erased(keep=id);
run;

proc sql noprint;
	select count(*) into :numb_ids
	from Erased;
	;
quit;

data names;
	set names;
	%all(name);/*this macro is changing the varibale vales in names table*/ /*but my condition should be if the values meets from the erased table then change the values in name table elase don't change*/
run;

/*this logic need to apply for the all the tables in all libraries*/&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;SS&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 09:21:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449249#M113043</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-28T09:21:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply variable values in other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449254#M113046</link>
      <description>Could you post the macro %all logic. It would be easy for us that way.</description>
      <pubDate>Wed, 28 Mar 2018 10:02:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449254#M113046</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-03-28T10:02:55Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply variable values in other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449255#M113047</link>
      <description>&lt;P&gt;Thanks Satish,&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro var(ds,var);
		if &amp;amp;var ne ' ' then
			&amp;amp;var = "xxxxx";	
%mend var;


%macro all(ds);
%var(&amp;amp;ds,var);
%mend all;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Mar 2018 10:12:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449255#M113047</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-28T10:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply variable values in other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449259#M113050</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data names;
	set names;
	%all(name);
	where id in (Erased);/*((this kind of approach i am looking for)*/
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Mar 2018 10:30:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449259#M113050</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-28T10:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply variable values in other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449260#M113051</link>
      <description>&lt;P&gt;Sorry, still not able to co-relate use of&amp;nbsp;Erased(id) in names dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The problem(macro var) you stated can be&amp;nbsp;solved using a simple match merge or sql join.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please elaborate your problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 10:31:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449260#M113051</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-03-28T10:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply variable values in other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449267#M113056</link>
      <description>&lt;P&gt;a dataseet&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Name&amp;nbsp;Sex&amp;nbsp;Age&amp;nbsp;Height&amp;nbsp;Weight&amp;nbsp;id&lt;BR /&gt;Alfred&amp;nbsp;M&amp;nbsp;14&amp;nbsp;69&amp;nbsp;112.5&amp;nbsp;1&lt;BR /&gt;Alice&amp;nbsp;F&amp;nbsp;13&amp;nbsp;56.5&amp;nbsp;84&amp;nbsp;2&lt;BR /&gt;Barbara&amp;nbsp;F&amp;nbsp;13&amp;nbsp;65.3&amp;nbsp;98&amp;nbsp;3&lt;BR /&gt;Carol&amp;nbsp;F&amp;nbsp;14&amp;nbsp;62.8&amp;nbsp;102.5&amp;nbsp;4&lt;BR /&gt;Henry&amp;nbsp;M&amp;nbsp;14&amp;nbsp;63.5&amp;nbsp;102.5&amp;nbsp;5&lt;BR /&gt;James&amp;nbsp;M&amp;nbsp;12&amp;nbsp;57.3&amp;nbsp;83&amp;nbsp;6&lt;BR /&gt;Jane&amp;nbsp;F&amp;nbsp;12&amp;nbsp;59.8&amp;nbsp;84.5&amp;nbsp;7&lt;BR /&gt;Janet&amp;nbsp;F&amp;nbsp;15&amp;nbsp;62.5&amp;nbsp;112.5&amp;nbsp;8&lt;BR /&gt;Jeffrey&amp;nbsp;M&amp;nbsp;13&amp;nbsp;62.5&amp;nbsp;84&amp;nbsp;9&lt;BR /&gt;John&amp;nbsp;M&amp;nbsp;12&amp;nbsp;59&amp;nbsp;99.5&amp;nbsp;10&lt;BR /&gt;Joyce&amp;nbsp;F&amp;nbsp;11&amp;nbsp;51.3&amp;nbsp;50.5&amp;nbsp;11&lt;BR /&gt;Judy&amp;nbsp;F&amp;nbsp;14&amp;nbsp;64.3&amp;nbsp;90&amp;nbsp;12&lt;BR /&gt;Louise&amp;nbsp;F&amp;nbsp;12&amp;nbsp;56.3&amp;nbsp;77&amp;nbsp;13&lt;BR /&gt;Mary&amp;nbsp;F&amp;nbsp;15&amp;nbsp;66.5&amp;nbsp;112&amp;nbsp;14&lt;BR /&gt;Philip&amp;nbsp;M&amp;nbsp;16&amp;nbsp;72&amp;nbsp;150&amp;nbsp;15&lt;BR /&gt;Robert&amp;nbsp;M&amp;nbsp;12&amp;nbsp;64.8&amp;nbsp;128&amp;nbsp;16&lt;BR /&gt;Ronald&amp;nbsp;M&amp;nbsp;15&amp;nbsp;67&amp;nbsp;133&amp;nbsp;17&lt;BR /&gt;Thomas&amp;nbsp;M&amp;nbsp;11&amp;nbsp;57.5&amp;nbsp;85&amp;nbsp;18&lt;BR /&gt;William&amp;nbsp;M&amp;nbsp;15&amp;nbsp;66.5&amp;nbsp;112&amp;nbsp;19&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;b dataset;&lt;/P&gt;&lt;P&gt;id&lt;BR /&gt;10&lt;BR /&gt;11&lt;BR /&gt;12&lt;BR /&gt;13&lt;BR /&gt;14&lt;BR /&gt;15&lt;BR /&gt;16&lt;BR /&gt;17&lt;BR /&gt;18&lt;BR /&gt;19&lt;/P&gt;&lt;P&gt;now I want repalce the values of name varable with XXXX. if&amp;nbsp; the condition meets in b datasets(based on ID) elase don't change.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Mar 2018 10:44:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449267#M113056</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-28T10:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply variable values in other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449272#M113058</link>
      <description>&lt;P&gt;below logic is working but I want to make &amp;nbsp;that dynamic in macro&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data d;
	set a;
	
	if id in(10,11,12,13,14,15,16,17,18,19) then %all(a) ;

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Mar 2018 10:54:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449272#M113058</guid>
      <dc:creator>sathya66</dc:creator>
      <dc:date>2018-03-28T10:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply variable values in other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449273#M113059</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro var(ds,chnge_var,chk_var);
	case when a.&amp;amp;chk_var. in (select distinct &amp;amp;chk_var. from &amp;amp;ds.) then "xxxxx" else &amp;amp;chnge_var. as &amp;amp;chnge_var.
%mend var;

proc sql;
create table names as
select %var(ds=lib.Erased,chnge_var=Name,chk_var=id), Sex, Age, Height, id
from names a;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Easy way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data names;
merge names(in=a) lib.Erased(in=b);
by id;
if a=b then do;
	Name='xxxxxx';
end;
if a then output;
run;
/*Both dataset shorted by id*/&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Mar 2018 10:54:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449273#M113059</guid>
      <dc:creator>Satish_Parida</dc:creator>
      <dc:date>2018-03-28T10:54:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to apply variable values in other table.</title>
      <link>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449274#M113060</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=a;
by id;
run;

proc sort data=b;
by id;
run;

data want;
merge
  a (in=a)
  b (in=b)
;
by id;
if a;
if b then name = 'XXXX';
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Mar 2018 10:55:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/how-to-apply-variable-values-in-other-table/m-p/449274#M113060</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-03-28T10:55:53Z</dc:date>
    </item>
  </channel>
</rss>

