<?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: Assigning variables in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Assigning-variables/m-p/583291#M13943</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16600"&gt;@SASPhile&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could create the repetitive code, e.g., by PROC SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select catx('=',name,substr(name,2)) into :assign separated by '; ' 
from dictionary.columns
where libname='WORK' &amp;amp; memname='HAVE' &amp;amp; name eqt '_';
quit;

data want;
set have;
&amp;amp;assign;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 22 Aug 2019 18:24:57 GMT</pubDate>
    <dc:creator>FreelanceReinh</dc:creator>
    <dc:date>2019-08-22T18:24:57Z</dc:date>
    <item>
      <title>Assigning variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-variables/m-p/583277#M13939</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&amp;nbsp; I have a dataset with same variables starting with underscore and without underscore. I would want to assign (in a loop)all underscore varaibles to those without undsrscore. can you help me on this?&lt;/P&gt;&lt;P&gt;For eg.&lt;/P&gt;&lt;P&gt;_id&amp;nbsp; &amp;nbsp; &amp;nbsp;id&amp;nbsp; &amp;nbsp; &amp;nbsp; _name&amp;nbsp; &amp;nbsp;name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;hardcoding I can do this way:&lt;/P&gt;&lt;P&gt;_id=id;&lt;/P&gt;&lt;P&gt;_name=name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 17:38:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-variables/m-p/583277#M13939</guid>
      <dc:creator>SASPhile</dc:creator>
      <dc:date>2019-08-22T17:38:18Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-variables/m-p/583289#M13942</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
	_id='   ';
	id='abc';
	_name='   ';
	name='xyz';
	output;
run;

data want;
	set have;
	array ch[*] _character_;

	do i=1 to dim(ch);
		if   find( vname(ch[i]), '_') then
			ch[i]=vvaluex(compress(vname(ch[i]),'_'));
	end;

	drop i;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Aug 2019 18:19:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-variables/m-p/583289#M13942</guid>
      <dc:creator>r_behata</dc:creator>
      <dc:date>2019-08-22T18:19:01Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-variables/m-p/583291#M13943</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16600"&gt;@SASPhile&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could create the repetitive code, e.g., by PROC SQL:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql noprint;
select catx('=',name,substr(name,2)) into :assign separated by '; ' 
from dictionary.columns
where libname='WORK' &amp;amp; memname='HAVE' &amp;amp; name eqt '_';
quit;

data want;
set have;
&amp;amp;assign;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 22 Aug 2019 18:24:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-variables/m-p/583291#M13943</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2019-08-22T18:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Assigning variables</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Assigning-variables/m-p/583298#M13944</link>
      <description>&lt;P&gt;Do your really want to create another set of variables with the same values?&lt;/P&gt;
&lt;P&gt;Or do you really need to just Rename the ones that you have, such as for combining with another data set?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you use the Search bar at the top of your message for something like "Rename all Variables" you find a number of variations on that:&lt;/P&gt;
&lt;P&gt;Such as &lt;A href="https://communities.sas.com/t5/New-SAS-User/rename-a-whole-set-of-variable-adding-the-same-suffix-to-all-of/m-p/575358#M12845" target="_blank"&gt;https://communities.sas.com/t5/New-SAS-User/rename-a-whole-set-of-variable-adding-the-same-suffix-to-all-of/m-p/575358#M12845&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code example assigns the non_underscored variable value to an underscored name. That doesn't quite match your verbiage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this may work:&lt;/P&gt;
&lt;PRE&gt;%macro dummy;
Proc sql;
   select name into : varlist separated by " "
   from dictionary.columns
   where libname='WORK' and memname='HAVE'
      and substr(name,1,1)='_'
   ;
quit;

data work.want;
   set work.have;
   %do i= 1 %to %sysfunc(countw(&amp;amp;varlist.));
      %let var = %substr(%scan(&amp;amp;varlist., &amp;amp;i),2);
      _&amp;amp;var.= &amp;amp;var.;
     /* or &amp;amp;var. = _&amp;amp;var.; depending on actual direction*/
   %end;
run;
 
%mend;&lt;/PRE&gt;
&lt;P&gt;Which does assume that you have both Name and _Name for all the variables.&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2019 18:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Assigning-variables/m-p/583298#M13944</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-08-22T18:36:36Z</dc:date>
    </item>
  </channel>
</rss>

