<?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 create a macro variable with all variable in a dataset in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-macro-variable-with-all-variable-in-a-dataset/m-p/648152#M194093</link>
    <description>&lt;P&gt;Dear&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a macro with all name in a data set. Please suggest&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input a b c;
datalines;
1 2 3
3 4 4
;
proc sql;
select name into: var separated by ""
from one;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output needed:&lt;/P&gt;
&lt;P&gt;var=a b c&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 15 May 2020 20:27:10 GMT</pubDate>
    <dc:creator>knveraraju91</dc:creator>
    <dc:date>2020-05-15T20:27:10Z</dc:date>
    <item>
      <title>How to create a macro variable with all variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-macro-variable-with-all-variable-in-a-dataset/m-p/648152#M194093</link>
      <description>&lt;P&gt;Dear&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need to create a macro with all name in a data set. Please suggest&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data one;
input a b c;
datalines;
1 2 3
3 4 4
;
proc sql;
select name into: var separated by ""
from one;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;output needed:&lt;/P&gt;
&lt;P&gt;var=a b c&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 20:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-macro-variable-with-all-variable-in-a-dataset/m-p/648152#M194093</guid>
      <dc:creator>knveraraju91</dc:creator>
      <dc:date>2020-05-15T20:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a macro variable with all variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-macro-variable-with-all-variable-in-a-dataset/m-p/648153#M194094</link>
      <description>&lt;P&gt;Use dictionary.columns as source, where libname = 'WORK' and memname = 'ONE'.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2020 20:32:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-macro-variable-with-all-variable-in-a-dataset/m-p/648153#M194094</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-05-15T20:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a macro variable with all variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-macro-variable-with-all-variable-in-a-dataset/m-p/648254#M194152</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;two other approaches (avoiding dictionary.columns):&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* one way: */
data _null_; 
  length n $ 32000; 
  do di=open('sashelp.class', 'I') while(di ne 0); 
    do i=1 to attrn(di,'NVARS'); 
      n=catx(" ", n, varname(di,i)); 
    end; 
  end; 
  call symputx('var', n);
run; 

%put &amp;amp;=var;


/* second way */
proc transpose data = sashelp.cars(obs=0) out = _tmp(keep = _name_);
  var _all_;
run;
proc sql noprint;
  select _name_ 
  into :var separated by " "
  from _tmp;
  drop table _tmp;
quit;

%put &amp;amp;=var;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All the best&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2020 08:18:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-macro-variable-with-all-variable-in-a-dataset/m-p/648254#M194152</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2020-05-16T08:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a macro variable with all variable in a dataset</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-macro-variable-with-all-variable-in-a-dataset/m-p/648265#M194154</link>
      <description>&lt;P&gt;Yet another approach is to use PROC CONTENTS to determine the column names in your data set, and then PROC SQL to create the macro variable. I find this preferable to using dictionary tables, as the dictionary tables can be very slow if you have databases with lots of tables/variables opened, or if you have many LIBNAMEs active (or both).&lt;/P&gt;</description>
      <pubDate>Sat, 16 May 2020 10:50:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-macro-variable-with-all-variable-in-a-dataset/m-p/648265#M194154</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-05-16T10:50:40Z</dc:date>
    </item>
  </channel>
</rss>

