<?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: Create a summary file on discrete variable values (for a list of variables) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Create-a-summary-file-on-discrete-variable-values-for-a-list-of/m-p/321133#M70827</link>
    <description>&lt;PRE&gt;

data have;
input var1 var2 var3 var4;
datalines;
1 12 300 4
2 12 500 0
0 12 200 2
0 15 200 2
;run;
 
data name;
input name $;
datalines;
var1
var2
var3
;
run;

data _null_;
 set name end=last;
 if _n_=1 then call execute('proc sql;');
 call execute(cat('create table want_',strip(_n_),' as select distinct(',name,') as ',name,' from have;'));
 if last then call execute('quit;');
run;

data want;
 merge want_:;
run;


&lt;/PRE&gt;</description>
    <pubDate>Mon, 26 Dec 2016 04:26:04 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-12-26T04:26:04Z</dc:date>
    <item>
      <title>Create a summary file on discrete variable values (for a list of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-summary-file-on-discrete-variable-values-for-a-list-of/m-p/321110#M70820</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;I want to create a table that report the number of descrete value for each variables (listed in the name file).&lt;BR /&gt;it should look like the table "want"&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Since the list of variables I want to create report is 200+ variables, I need to make a code instead of doing it manually.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thank you for your help.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Merry Christmas and Happy New Year!&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;HHC&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data have;&lt;BR /&gt;input var1 var2 var3 var4;&lt;BR /&gt;datalines;&lt;BR /&gt;1 12 300 4&lt;BR /&gt;2 12 500 0&lt;BR /&gt;0 12 200 2&lt;BR /&gt;0 15 200 2&lt;BR /&gt;;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data name;&lt;BR /&gt;input name $;&lt;BR /&gt;datalines;&lt;BR /&gt;var1&lt;BR /&gt;var2&lt;BR /&gt;var3&lt;BR /&gt;;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;BR /&gt;input var1 var2 var3;&lt;BR /&gt;datalines;&lt;BR /&gt;1 12 300&lt;BR /&gt;2 15 500&lt;BR /&gt;0 . 200&lt;BR /&gt;;run;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2016 22:36:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-summary-file-on-discrete-variable-values-for-a-list-of/m-p/321110#M70820</guid>
      <dc:creator>hhchenfx</dc:creator>
      <dc:date>2016-12-25T22:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: Create a summary file on discrete variable values (for a list of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-summary-file-on-discrete-variable-values-for-a-list-of/m-p/321113#M70821</link>
      <description>&lt;P&gt;Maybe only part of what you want, the variables are stacked rather than each in their own column.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods table onewayfreqs=temp;
proc freq data=sashelp.class;
run;


*Format output;
data want;
length variable $32. variable_value $50.;
set temp;
Variable=scan(table, 2);

Variable_Value=strip(trim(vvaluex(variable)));

keep variable variable_value frequency percent cum:;
label variable='Variable' 
	variable_value='Variable Value';
run;

*Display;
proc print data=want(obs=20) label;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Slight mod from here:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/e0903d269d4a71316a4e" target="_blank"&gt;https://gist.github.com/statgeek/e0903d269d4a71316a4e&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2016 23:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-summary-file-on-discrete-variable-values-for-a-list-of/m-p/321113#M70821</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-12-25T23:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Create a summary file on discrete variable values (for a list of variables)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Create-a-summary-file-on-discrete-variable-values-for-a-list-of/m-p/321133#M70827</link>
      <description>&lt;PRE&gt;

data have;
input var1 var2 var3 var4;
datalines;
1 12 300 4
2 12 500 0
0 12 200 2
0 15 200 2
;run;
 
data name;
input name $;
datalines;
var1
var2
var3
;
run;

data _null_;
 set name end=last;
 if _n_=1 then call execute('proc sql;');
 call execute(cat('create table want_',strip(_n_),' as select distinct(',name,') as ',name,' from have;'));
 if last then call execute('quit;');
run;

data want;
 merge want_:;
run;


&lt;/PRE&gt;</description>
      <pubDate>Mon, 26 Dec 2016 04:26:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Create-a-summary-file-on-discrete-variable-values-for-a-list-of/m-p/321133#M70827</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-12-26T04:26:04Z</dc:date>
    </item>
  </channel>
</rss>

