<?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: Proc Freq &amp;amp; Proc Mean in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772561#M245314</link>
    <description>&lt;P&gt;Something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=inputDatasetName;
table SingleVariable orListOfVarsSpaceDelimited;
run;

proc freq data=sashelp.class;
table sex age name;
table sex;
table age;
table sex*age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Maybe this tutorial would be helpful:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://libguides.library.kent.edu/SAS/Frequencies" target="_blank"&gt;https://libguides.library.kent.edu/SAS/Frequencies&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 06 Oct 2021 20:22:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2021-10-06T20:22:29Z</dc:date>
    <item>
      <title>Proc Freq &amp; Proc Mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772537#M245303</link>
      <description>&lt;P&gt;Hi, I currently have a proc freq macro.&lt;BR /&gt;How do I separate these into separate proc freq's for each variable?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: I have 13 categorical variables and 2 numerical variables.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*looping through all categorical variables for proc freq exports*/
%macro freq_loop;
%Do i=1 %to &amp;amp;num_cats.;
	%let j=%scan(&amp;amp;cat_vars.,&amp;amp;i.);

proc freq data=&amp;amp;filetype._stacked order=freq; 
	table &amp;amp;j. / out=freqs_&amp;amp;j. ;
	by year;
run;

PROC EXPORT DATA=freqs_&amp;amp;j.
	OUTFILE="&amp;amp;results.\&amp;amp;filetype._ProcFreq_&amp;amp;date..csv"
	dbms=xlsx replace;
	sheet= "&amp;amp;j.";
RUN;

%end;
%mend;
%freq_loop;

/*looping through all numerical variables for proc means exports*/
%macro means_loop;
%Do i=1 %to &amp;amp;num_nums.;
	%let j=%scan(&amp;amp;num_vars.,&amp;amp;i.);

proc means data=&amp;amp;filetype._stacked; 
	var &amp;amp;j.;
	by year;
	output out=means_&amp;amp;j. (where=(_STAT_ IN ("MIN", "MEAN", "MAX"))drop=_TYPE_ _FREQ_);
run;

PROC EXPORT DATA=means_&amp;amp;j.
	OUTFILE="&amp;amp;results.\&amp;amp;filetype._ProcMeans_&amp;amp;date..csv"
	dbms=xlsx replace;
	sheet= "&amp;amp;j.";
RUN;
%end;
%mend;
%means_loop;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Thank you in advance,&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 19:10:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772537#M245303</guid>
      <dc:creator>leeleelee</dc:creator>
      <dc:date>2021-10-06T19:10:34Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq &amp; Proc Mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772546#M245308</link>
      <description>That's already what it's doing - it does it by year though. Are you asking how to do it not by year as well?&lt;BR /&gt;&lt;BR /&gt;FYI - CSVs do not support multiple sheets, its a single file so you cannot export with a CSV extension, specify the DBMX=XLSX and a sheet name. Also, have you considered using ODS EXCEL instead of EXPORTS?&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 06 Oct 2021 19:21:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772546#M245308</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-06T19:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq &amp; Proc Mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772559#M245313</link>
      <description>&lt;P&gt;Hello,&lt;BR /&gt;&lt;BR /&gt;I am wondering how to take it out of the macro (a.k.a. the looping), group by year (I have a total of 12 years)&lt;BR /&gt;I want to write it out for example (I know this code is wrong):&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq cat_var ...&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and thank you for the csv tip. I'll note it.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 20:06:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772559#M245313</guid>
      <dc:creator>leeleelee</dc:creator>
      <dc:date>2021-10-06T20:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq &amp; Proc Mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772561#M245314</link>
      <description>&lt;P&gt;Something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=inputDatasetName;
table SingleVariable orListOfVarsSpaceDelimited;
run;

proc freq data=sashelp.class;
table sex age name;
table sex;
table age;
table sex*age;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Maybe this tutorial would be helpful:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://libguides.library.kent.edu/SAS/Frequencies" target="_blank"&gt;https://libguides.library.kent.edu/SAS/Frequencies&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 20:22:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772561#M245314</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-10-06T20:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Freq &amp; Proc Mean</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772563#M245315</link>
      <description>&lt;P&gt;I'll try this out and will see if it works!&lt;BR /&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 20:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Proc-Freq-amp-Proc-Mean/m-p/772563#M245315</guid>
      <dc:creator>leeleelee</dc:creator>
      <dc:date>2021-10-06T20:16:43Z</dc:date>
    </item>
  </channel>
</rss>

