<?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: How to create macro variable list? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/372634#M276103</link>
    <description>&lt;P&gt;Easiest way to create a macro variable list, methinks, is with proc sql. But you'd have to tell us more about how you want to use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 03 Jul 2017 01:11:44 GMT</pubDate>
    <dc:creator>art297</dc:creator>
    <dc:date>2017-07-03T01:11:44Z</dc:date>
    <item>
      <title>How to create macro variable list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/372626#M276101</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a program shown below.&amp;nbsp;&amp;nbsp; To get the macro Ns, I need to write twenty times 'array', 'call symputx' 'proc transpose'.&amp;nbsp;&amp;nbsp; My sample data set is shown in the attachment, it only shows three groups 'bd_dx', 'state_id' and 'if_img'.&amp;nbsp; However I have 20 more groups in the actural sample.&amp;nbsp; Is there a way to approach this more efficient?&amp;nbsp;Maybe create a macro&amp;nbsp;varialbe list to refere all of these groups?&amp;nbsp; Please help.&amp;nbsp; Thanks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Name $ bd_dx_1-bd_dx_6 State_ID_1-State_ID_4 If_img_1-If_img_8;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;A 0.57 0.015 0.371 0.927 0.16 0.336 0.153 0.461 0.342 0.056 0.698 0.165 0.019 0.5&lt;/P&gt;&lt;P&gt;0.413 0.184 0.637 0.689&lt;/P&gt;&lt;P&gt;B 0.512 0.811 0.62 0.293 0.42 0.223 0.809 0.893 0.483 0.714 0.836 0.231 0.314 0.057&lt;/P&gt;&lt;P&gt;0.177 0.698 0.44 0.384&lt;/P&gt;&lt;P&gt;C 0.406 0.313 0.672 0.234 0.759 0.328 0.895 0.004 0.659 0.209 0.449 0.927 0.343 0.368&lt;/P&gt;&lt;P&gt;0.776 0.114 0.073 0.316&lt;/P&gt;&lt;P&gt;D 0.995 0.69 0.487 0.491 0.511 0.288 0.411 0.712 0.17 0.055 0.233 0.465 0.264 0.615&lt;/P&gt;&lt;P&gt;0.807 0.614 0.48 0.262&lt;/P&gt;&lt;P&gt;E 0.193 0.144 0.501 0.576 0.033 0.51 0.999 0.302 0.392 0.048 0.852 0.865 0.96 0.31&lt;/P&gt;&lt;P&gt;0.267 0.998 0.9 0.042&lt;/P&gt;&lt;P&gt;F 0.686 0.103 0.617 0.173 0.538 0.209 0.887 0.824 0.035 0.426 0.642 0.998 0.884 0.525&lt;/P&gt;&lt;P&gt;0.737 0.52 0.744 0.292&lt;/P&gt;&lt;P&gt;;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; want;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=name);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; bd_dx(*) bd_dx: ;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; symputx(&lt;/FONT&gt;&lt;FONT color="#800080" face="Courier New" size="2"&gt;'d_bd'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,dim(bd_dx));&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;stop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; temp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test (&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;keep&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=name bd_dx_1-bd_dx_&amp;amp;d_bd);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=temp &lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=trans1&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;prefix&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=bd_dx;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; bd_dx_1-bd_dx_&amp;amp;d_bd;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Name; &lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 17:40:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/372626#M276101</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-05T17:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/372628#M276102</link>
      <description>&lt;P&gt;&lt;A href="http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset" target="_blank"&gt;http://www.sascommunity.org/wiki/A_Better_Way_to_Flip_(Transpose)_a_SAS_Dataset&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The macro above may be helpful.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 00:17:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/372628#M276102</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-03T00:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/372634#M276103</link>
      <description>&lt;P&gt;Easiest way to create a macro variable list, methinks, is with proc sql. But you'd have to tell us more about how you want to use it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Art, CEO, AnalystFinder.com&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 01:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/372634#M276103</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2017-07-03T01:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/372655#M276104</link>
      <description>&lt;P&gt;And supply your example data in a data step. Excel files don't convey the important attributes of SAS datasets. And many of us can't open them from the internet for security reasons.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Jul 2017 06:25:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/372655#M276104</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-07-03T06:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373335#M276105</link>
      <description>&lt;P&gt;I have provided sample test data set above.&amp;nbsp;&amp;nbsp; Basely, when I transpose 'bd_dx'&amp;nbsp; involving three steps, list above.&amp;nbsp; However, my actual dataset contains 20 subgroups similar as 'bd_dx', 'state_id', and 'if_img', etc.&amp;nbsp;&amp;nbsp; I need to write twenty steps to do transpose for each subgroup.&amp;nbsp;&amp;nbsp; I am really looking for a macro program to impletement these steps.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 15:24:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373335#M276105</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-05T15:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373364#M276106</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;Please do not edit your post to change your question after you've had responses. It makes the whole thread not make sense. If you need to add supporting information do so in a new post.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 17:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373364#M276106</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-05T17:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373372#M276107</link>
      <description>&lt;P&gt;Hello:&lt;/P&gt;&lt;P&gt;I edited my post base on the Kurt request due to the Excel file is not safe to be opened.&amp;nbsp; I provided my sample data set on my oringinal post.&amp;nbsp;&amp;nbsp; I hope it make easier for the people to read.&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 17:39:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373372#M276107</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2017-07-05T17:39:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373376#M276108</link>
      <description>&lt;P&gt;What is it that you are trying to put into a list?&lt;/P&gt;
&lt;P&gt;It looks like you have a number fo variables with numeric prefixes and you want to transpose them?&lt;/P&gt;
&lt;P&gt;Assuming that your lists all include one variable that ends with _1 then you could make the list this way.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc contents data=have out=contents noprint; run;
proc sql noprint ;
  select substr(name,1,length(name)-2) 
    into :list separated by ' '
  from contents
  where name like '%_1'
  ;
%let ngroups=&amp;amp;sqlobs;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then if you are writing this in a macro you can add %DO loop to transpose the groups.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i=1 %to &amp;amp;ngroups;
%let prefix=%scan(&amp;amp;list,&amp;amp;i);
proc transpose data=have(keep=name &amp;amp;prefix.:)
  out=group&amp;amp;i (rename=(col1=&amp;amp;prefix) drop=_name_)
;
  by name;
  var &amp;amp;prefix.: ;
run;
%end;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 05 Jul 2017 17:46:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373376#M276108</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-07-05T17:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to create macro variable list?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373400#M276109</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;Hello:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a program shown below.&amp;nbsp;&amp;nbsp; To get the macro Ns, I need to write twenty times 'array', 'call symputx' 'proc transpose'.&amp;nbsp;&amp;nbsp; My sample data set is shown in the attachment, it only shows three groups 'bd_dx', 'state_id' and 'if_img'.&amp;nbsp; However I have 20 more groups in the actural sample.&amp;nbsp; Is there a way to approach this more efficient?&amp;nbsp;Maybe create a macro&amp;nbsp;varialbe list to refere all of these groups?&amp;nbsp; Please help.&amp;nbsp; Thanks.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;input&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Name $ bd_dx_1-bd_dx_6 State_ID_1-State_ID_4 If_img_1-If_img_8;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;cards&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;A 0.57 0.015 0.371 0.927 0.16 0.336 0.153 0.461 0.342 0.056 0.698 0.165 0.019 0.5&lt;/P&gt;
&lt;P&gt;0.413 0.184 0.637 0.689&lt;/P&gt;
&lt;P&gt;B 0.512 0.811 0.62 0.293 0.42 0.223 0.809 0.893 0.483 0.714 0.836 0.231 0.314 0.057&lt;/P&gt;
&lt;P&gt;0.177 0.698 0.44 0.384&lt;/P&gt;
&lt;P&gt;C 0.406 0.313 0.672 0.234 0.759 0.328 0.895 0.004 0.659 0.209 0.449 0.927 0.343 0.368&lt;/P&gt;
&lt;P&gt;0.776 0.114 0.073 0.316&lt;/P&gt;
&lt;P&gt;D 0.995 0.69 0.487 0.491 0.511 0.288 0.411 0.712 0.17 0.055 0.233 0.465 0.264 0.615&lt;/P&gt;
&lt;P&gt;0.807 0.614 0.48 0.262&lt;/P&gt;
&lt;P&gt;E 0.193 0.144 0.501 0.576 0.033 0.51 0.999 0.302 0.392 0.048 0.852 0.865 0.96 0.31&lt;/P&gt;
&lt;P&gt;0.267 0.998 0.9 0.042&lt;/P&gt;
&lt;P&gt;F 0.686 0.103 0.617 0.173 0.538 0.209 0.887 0.824 0.035 0.426 0.642 0.998 0.884 0.525&lt;/P&gt;
&lt;P&gt;0.737 0.52 0.744 0.292&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; want;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;drop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=name);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;array&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; bd_dx(*) bd_dx: ;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;call&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; symputx(&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#800080"&gt;'d_bd'&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;,dim(bd_dx));&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;stop&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;data&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; temp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;set&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; test (&lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;keep&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=name bd_dx_1-bd_dx_&amp;amp;d_bd);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;transpose&lt;/FONT&gt;&lt;/STRONG&gt; &lt;FONT face="Courier New" size="2" color="#0000ff"&gt;data&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=temp &lt;/FONT&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;out&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=trans1&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;prefix&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;=bd_dx;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;var&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; bd_dx_1-bd_dx_&amp;amp;d_bd;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#0000ff"&gt;by&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt; Name; &lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;run&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face="Courier New" size="2" color="#000080"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are all variables numeric or do you have character ones interspersed in there? Your sample shows all numeric, which means this is trivial to do in array&amp;nbsp;loops.&amp;nbsp;Transpose to long and then re-transpose again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data test;
	input Name $ bd_dx_1-bd_dx_6 State_ID_1-State_ID_4 If_img_1-If_img_8;
	cards;
A 0.57 0.015 0.371 0.927 0.16 0.336 0.153 0.461 0.342 0.056 0.698 0.165 0.019 0.5
0.413 0.184 0.637 0.689
B 0.512 0.811 0.62 0.293 0.42 0.223 0.809 0.893 0.483 0.714 0.836 0.231 0.314 0.057
0.177 0.698 0.44 0.384
C 0.406 0.313 0.672 0.234 0.759 0.328 0.895 0.004 0.659 0.209 0.449 0.927 0.343 0.368
0.776 0.114 0.073 0.316
D 0.995 0.69 0.487 0.491 0.511 0.288 0.411 0.712 0.17 0.055 0.233 0.465 0.264 0.615
0.807 0.614 0.48 0.262
E 0.193 0.144 0.501 0.576 0.033 0.51 0.999 0.302 0.392 0.048 0.852 0.865 0.96 0.31
0.267 0.998 0.9 0.042
F 0.686 0.103 0.617 0.173 0.538 0.209 0.887 0.824 0.035 0.426 0.642 0.998 0.884 0.525
0.737 0.52 0.744 0.292
;
run;

data long;
	set test;
	array flip(*) bd_dx_1 -- if_img_8;

	do i=1 to dim(flip);
		v_name=vname(flip(i));
		v_value=flip(i);
		group=prxchange('s/\_\d+$//', 1, trim(v_name));
		index=scan(v_name, -1, "_");
		output;
	end;
	keep name group index v_name v_value;
run;

proc sort data=long;
	by name index group;
run;

proc transpose data=long out=wide;
	by name index;
	id group;
	var v_value;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Jul 2017 18:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-macro-variable-list/m-p/373400#M276109</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-07-05T18:35:28Z</dc:date>
    </item>
  </channel>
</rss>

