<?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 Print Formatting in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686828#M24483</link>
    <description>&lt;P&gt;Am still having errors. I did created an output using proc freq which looks like the data below&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Number of Survey&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Freq&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Percent&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;30&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;5&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;50&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;30.9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;from here, I have followed what recommended below but I am not able to get the table I wanted.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   length Participants $ 15;
   participants = catx(' ',frequency,cats('(',put(percent,f3.0),')'));
   label participants='Number of participants (%)';
run;

proc print data=want noobs label;
  var participants surveys;
run;, &amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;,&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 25 Sep 2020 20:56:23 GMT</pubDate>
    <dc:creator>hjjijkkl</dc:creator>
    <dc:date>2020-09-25T20:56:23Z</dc:date>
    <item>
      <title>Proc Freq Formatting</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686803#M24477</link>
      <description>&lt;P&gt;Is it possible to proc freq output that is something like this&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;Number of participants (%)&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Number of surveys&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;1030 (27)&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;100 (24)&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;instead of the regular output which is down below.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Frequency Count&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;Number of surveys&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Frequency&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;Percent&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;1&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;1030&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;27&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD&gt;
&lt;P&gt;2&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;100&lt;/P&gt;
&lt;/TD&gt;
&lt;TD&gt;
&lt;P&gt;24&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I was told you can use proc freq and the use proc print (w/ formatting) but, am confused. Please help!&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 19:12:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686803#M24477</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-09-25T19:12:37Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Formatting</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686811#M24479</link>
      <description>&lt;P&gt;Why is the question subject "Proc Print" when the question is for Proc Freq.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To have multiple values in a single "cell" you will need to make a single value in a dataset, which Proc Freq and basically none of the procedures will do, and then use something else to display the result, such as Proc Print or Report.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you would use proc freq to create an output data set and then do something like:&lt;/P&gt;
&lt;P&gt;Assumes the data set you created from Proc freq is named "have".&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   length Participants $ 15;
   participants = catx(' ',Count,cats('(',put(percent,f3.0),')'));
   label participants='Number of participants (%)';
run;

proc print data=want noobs label;
  var participants surveys;
run;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Sep 2020 21:48:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686811#M24479</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-25T21:48:00Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Formatting</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686817#M24481</link>
      <description>&lt;P&gt;You cannot do this within PROC FREQ. You can customize your formats, layout and measures in PROC TABULATE more easily but it still won't give you exactly what you want there. The approach to generate those types of tables is to put your results from FREQ into a data set, create the variables you want and how you want to display them and then print that data set.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another option is to use macros that other people have written but you're then stuck with their options and preferences so usually I write my own to suit my preferences.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/Demographic-Table-and-Subgroup-Summary-Macro-TABLEN/ta-p/634030&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a one way table here's one method, a bit longer for sure though.&amp;nbsp;&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;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*This code is an example of how to generate a table with 
Variable Name, Variable Value, Frequency, Percent, Cumulative Freq and Cum Pct
No macro's are required
Use Proc Freq to generate the list, list variables in a table statement if only specific variables are desired
Use ODS Table to capture the output and then format the output into a printable table.
*/

*Run frequency for tables;
ods table onewayfreqs=temp;
proc freq data=sashelp.class;
	table sex age;
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;And examples of custom macros:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://gist.github.com/statgeek/c099e294e2a8c8b5580a" target="_blank"&gt;https://gist.github.com/statgeek/c099e294e2a8c8b5580a&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 19:38:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686817#M24481</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-09-25T19:38:28Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Formatting</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686828#M24483</link>
      <description>&lt;P&gt;Am still having errors. I did created an output using proc freq which looks like the data below&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;Number of Survey&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Freq&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Percent&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;2&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;30&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;2.5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;5&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;50&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;30.9&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;from here, I have followed what recommended below but I am not able to get the table I wanted.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data want;
   set have;
   length Participants $ 15;
   participants = catx(' ',frequency,cats('(',put(percent,f3.0),')'));
   label participants='Number of participants (%)';
run;

proc print data=want noobs label;
  var participants surveys;
run;, &amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 20:56:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686828#M24483</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-09-25T20:56:23Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Formatting</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686832#M24484</link>
      <description>&lt;P&gt;So, what is not correct with the output???? Details matter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Doesn't work is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the &amp;lt;&amp;gt; to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat&lt;/A&gt;... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You have changed the values but are not showing the expected output.&lt;/P&gt;
&lt;P&gt;And my variables may not match your names because you did not provide variable names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Provide examp&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 21:10:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686832#M24484</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-25T21:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Formatting</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686836#M24485</link>
      <description>&lt;P&gt;Sorry. it wasn't error that i was getting but, this is the print out after following your guidance. Thank you!&lt;/P&gt;
&lt;TABLE width="130"&gt;
&lt;THEAD&gt;
&lt;TR&gt;
&lt;TD width="129.333px" height="84px"&gt;
&lt;P&gt;Number of &lt;BR /&gt;participants &lt;BR /&gt;(%)&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;/THEAD&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="129.333px" height="29px"&gt;
&lt;P&gt;. (27)&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="129.333px" height="29px"&gt;
&lt;P&gt;. (25)&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="129.333px" height="29px"&gt;
&lt;P&gt;. (17)&lt;/P&gt;
&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="129.333px" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="129.333px" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="129.333px" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="129.333px" height="29px"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Fri, 25 Sep 2020 21:26:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686836#M24485</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-09-25T21:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Formatting</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686844#M24489</link>
      <description>&lt;P&gt;use Count&amp;nbsp; not Frequency in the CATX statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Check the names of your varaibles in a data set. Always.&lt;/P&gt;</description>
      <pubDate>Fri, 25 Sep 2020 21:48:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686844#M24489</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-09-25T21:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc Print Formatting</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686851#M24491</link>
      <description>Thank you! &lt;BR /&gt;There is still an issue. the first column "Number of Survey"  do I add that to proc print? And How? Please the data below for reference.&lt;BR /&gt;this is what am proc freq "have" look like&lt;BR /&gt;Number of Survey 	Freq	  Percent &lt;BR /&gt;1	                        30    	2.5&lt;BR /&gt;2	                       50	      30.9&lt;BR /&gt;&lt;BR /&gt;This is how I would want the table to look like at the end&lt;BR /&gt;Number of participants (%)         Number of surveys &lt;BR /&gt;1030 (27)                                        1&lt;BR /&gt;100 (24)                                          2&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Sep 2020 22:15:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Proc-Freq-Formatting/m-p/686851#M24491</guid>
      <dc:creator>hjjijkkl</dc:creator>
      <dc:date>2020-09-25T22:15:35Z</dc:date>
    </item>
  </channel>
</rss>

