<?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: Output dataset of proc univariate stats for multiple variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Output-dataset-of-proc-univariate-stats-for-multiple-variables/m-p/61772#M17533</link>
    <description>Hi:&lt;BR /&gt;
  You have 2 choices:&lt;BR /&gt;
1) Use Univariate internal OUTPUT syntax to name the variables listed in your VAR statement or&lt;BR /&gt;
2) Use ODS OUTPUT syntax to get the "BASICMEASURES" output object that will contain all the info for the variables listed in the VAR statement.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
** 1) Use Univariate OUTPUT statement to create multiple variables;&lt;BR /&gt;
ods trace on /label;&lt;BR /&gt;
proc univariate data = sashelp.class;&lt;BR /&gt;
var age weight height;&lt;BR /&gt;
output out = my_output_dataset&lt;BR /&gt;
median =medage medwt medht&lt;BR /&gt;
mean =mnage mnwt mnht&lt;BR /&gt;
mode =modage modwt modht ;&lt;BR /&gt;
run;&lt;BR /&gt;
ods trace off;&lt;BR /&gt;
                       &lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc print data=my_output_dataset;&lt;BR /&gt;
  title '1) Using Internal OUTPUT statement';&lt;BR /&gt;
run;&lt;BR /&gt;
                          &lt;BR /&gt;
** 2) use ODS OUTPUT statement;&lt;BR /&gt;
ods output basicmeasures=work.all_basic;&lt;BR /&gt;
proc univariate data = sashelp.class;&lt;BR /&gt;
var age weight height;&lt;BR /&gt;
run;&lt;BR /&gt;
                                           &lt;BR /&gt;
proc print data=work.all_basic;&lt;BR /&gt;
  title '2) Using ODS OUTPUT';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
    <pubDate>Wed, 12 Jan 2011 21:08:48 GMT</pubDate>
    <dc:creator>Cynthia_sas</dc:creator>
    <dc:date>2011-01-12T21:08:48Z</dc:date>
    <item>
      <title>Output dataset of proc univariate stats for multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Output-dataset-of-proc-univariate-stats-for-multiple-variables/m-p/61771#M17532</link>
      <description>The current code...&lt;BR /&gt;
&lt;BR /&gt;
proc univariate data = my_input_dataset;&lt;BR /&gt;
  var age weight height;&lt;BR /&gt;
  output out = my_output_dataset&lt;BR /&gt;
         median = median&lt;BR /&gt;
         mean = mean&lt;BR /&gt;
         mode = mode&lt;BR /&gt;
         ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
So this appears to output the stats for "age", but then overwrites with the stats for "weight", and finally "height". So I only end up with one row containing the stats for the most recent variable. &lt;BR /&gt;
&lt;BR /&gt;
Can the univariate procedure create a dataset with the stats for all of these variables (ie, without having to throw in some data steps and loop, etc)? In which case, is there a way to throw in the variable name to distinguish the rows?</description>
      <pubDate>Wed, 12 Jan 2011 20:26:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Output-dataset-of-proc-univariate-stats-for-multiple-variables/m-p/61771#M17532</guid>
      <dc:creator>jawon</dc:creator>
      <dc:date>2011-01-12T20:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Output dataset of proc univariate stats for multiple variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Output-dataset-of-proc-univariate-stats-for-multiple-variables/m-p/61772#M17533</link>
      <description>Hi:&lt;BR /&gt;
  You have 2 choices:&lt;BR /&gt;
1) Use Univariate internal OUTPUT syntax to name the variables listed in your VAR statement or&lt;BR /&gt;
2) Use ODS OUTPUT syntax to get the "BASICMEASURES" output object that will contain all the info for the variables listed in the VAR statement.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
[pre]&lt;BR /&gt;
** 1) Use Univariate OUTPUT statement to create multiple variables;&lt;BR /&gt;
ods trace on /label;&lt;BR /&gt;
proc univariate data = sashelp.class;&lt;BR /&gt;
var age weight height;&lt;BR /&gt;
output out = my_output_dataset&lt;BR /&gt;
median =medage medwt medht&lt;BR /&gt;
mean =mnage mnwt mnht&lt;BR /&gt;
mode =modage modwt modht ;&lt;BR /&gt;
run;&lt;BR /&gt;
ods trace off;&lt;BR /&gt;
                       &lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc print data=my_output_dataset;&lt;BR /&gt;
  title '1) Using Internal OUTPUT statement';&lt;BR /&gt;
run;&lt;BR /&gt;
                          &lt;BR /&gt;
** 2) use ODS OUTPUT statement;&lt;BR /&gt;
ods output basicmeasures=work.all_basic;&lt;BR /&gt;
proc univariate data = sashelp.class;&lt;BR /&gt;
var age weight height;&lt;BR /&gt;
run;&lt;BR /&gt;
                                           &lt;BR /&gt;
proc print data=work.all_basic;&lt;BR /&gt;
  title '2) Using ODS OUTPUT';&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]</description>
      <pubDate>Wed, 12 Jan 2011 21:08:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Output-dataset-of-proc-univariate-stats-for-multiple-variables/m-p/61772#M17533</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2011-01-12T21:08:48Z</dc:date>
    </item>
  </channel>
</rss>

