<?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: Concatenating macro variables in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378018#M24586</link>
    <description>YOU ARE A GENIUS! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
    <pubDate>Fri, 21 Jul 2017 06:58:11 GMT</pubDate>
    <dc:creator>ayin</dc:creator>
    <dc:date>2017-07-21T06:58:11Z</dc:date>
    <item>
      <title>Concatenating macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378007#M24584</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let have1 = var1 var2 var3;
%let have2 = a b c;
%let want = a.var1=b.var1=c.var1 a.var2=b.var2=c.var2 a.var3=b.var3=c.var3;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Codes above used to generate input and output data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm thinking about using 2 loops, and something like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro sample;

%do _i = 1 %to %sysfunc(countw(&amp;amp;have1));

%let want&amp;amp;_i = ... /* e.g. want1 = a.var1=b.var1=c.var1 */

%end;

%global want;
%let want = ... /* e.g. &amp;amp;want1 || &amp;amp;want2 || &amp;amp;want3 */

%mend sample;
%sample;

%put &amp;amp;want;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Because have1 and have2 can have a different number of words, hardcoding will not be accepted.&lt;/P&gt;&lt;P&gt;If someone can show me at least how to generate &amp;amp;want1 that'd be awesome!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 06:22:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378007#M24584</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-07-21T06:22:35Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378015#M24585</link>
      <description>&lt;P&gt;Do it in a data step:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _null_;
length outstring $100 intstring $30;
have1 = 'var1 var2 var3';
have2 = 'a b c';
do i = 1 to countw(have1);
  intstring = '';
  do j = 1 to countw(have2);
    intstring = catx('=',intstring,trim(scan(have2,j))!!'.'!!trim(scan(have1,i)));
  end;
  outstring=catx(' ',outstring,intstring);
end;
call symput('want',trim(outstring));
run;
%put &amp;amp;want;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2017 06:50:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378015#M24585</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-21T06:50:50Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378018#M24586</link>
      <description>YOU ARE A GENIUS! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Fri, 21 Jul 2017 06:58:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378018#M24586</guid>
      <dc:creator>ayin</dc:creator>
      <dc:date>2017-07-21T06:58:11Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378022#M24587</link>
      <description>&lt;P&gt;"&lt;SPAN&gt;Because have1 and have2 can have a different number of words, hardcoding will not be accepted." - This is nonsense. &amp;nbsp;SAS, SQL and such like are data based programming languages, i.e. they are specifically designed to work with data. &amp;nbsp;If you have an unknown amount of join variables, then these should not be variables at all, they should be data rows. &amp;nbsp;Joins&amp;nbsp;&lt;STRONG&gt;should&lt;/STRONG&gt; be hardocded in - i.e. your process shouldl know the data it is dealing with otherwise you will never know what you will get out or if it even worked. &amp;nbsp;Its a fundamental basic of data based programming, know your data, model your data appropriately. &amp;nbsp;I need to merge X datasets, data looks like:&lt;BR /&gt;VAR1 VAR2 VAR3...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;4 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I do not know the number of these, so proc transpose to normalise them to get:&lt;BR /&gt;VAR_NO &amp;nbsp; RESULT&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;1 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;3 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 2&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Then I merge the data based on var_no=var_no plus any other identifers. &amp;nbsp;Then if I really need a normalised dataset, then I proc transpose the data back up (or array the data back depending on the types involved). &amp;nbsp;Simple, no loops, no guess work, no spaghetti code which falls over every other time its run, just plain simple Base SAS and data modelling.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 21 Jul 2017 08:16:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378022#M24587</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-07-21T08:16:00Z</dc:date>
    </item>
    <item>
      <title>Re: Concatenating macro variables</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378076#M24591</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let have1 = var1 var2 var3;
%let have2 = a b c;

%macro sample;
%global want;
%let want= ;
%do _i=1 %to %sysfunc(countw(&amp;amp;have1));
 %let dim==;
 %do _j=1 %to %sysfunc(countw(&amp;amp;have2));
   %if &amp;amp;_j=%sysfunc(countw(&amp;amp;have2)) %then %let dim=%str( ) ; 
   %let want=&amp;amp;want%scan(&amp;amp;have2,&amp;amp;_j).%scan(&amp;amp;have1,&amp;amp;_i)&amp;amp;dim;
 %end;
%end;
%mend sample;
%sample

%put &amp;amp;want;


&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 21 Jul 2017 11:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Concatenating-macro-variables/m-p/378076#M24591</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-07-21T11:18:45Z</dc:date>
    </item>
  </channel>
</rss>

