<?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: Table restructuring in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/868356#M343025</link>
    <description>Thank you, sir. It is a class work, I will research the %tableN.&lt;BR /&gt;Thanks for your response.&lt;BR /&gt;</description>
    <pubDate>Wed, 05 Apr 2023 21:14:30 GMT</pubDate>
    <dc:creator>PrinceAde</dc:creator>
    <dc:date>2023-04-05T21:14:30Z</dc:date>
    <item>
      <title>Table restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867649#M342688</link>
      <description>The 15(100%) are concatenated products of count and percent using proc freq, I eventually got dataset A using proc transpose, but my final destination should be B, with two columns Active and Placebo. The Gender is a row with an empty value for the columns.&lt;BR /&gt;Please how can I arrive at B using dataset A, any idea what I can do?&lt;BR /&gt;Thank you.&lt;BR /&gt;&lt;BR /&gt;A&lt;BR /&gt;Gender active placebo&lt;BR /&gt;Male 15(100%) 13(100%)&lt;BR /&gt;Female 15(100%) 13(100%)&lt;BR /&gt;&lt;BR /&gt;B&lt;BR /&gt;active placebo&lt;BR /&gt;Gender&lt;BR /&gt;Male 15(100%) 13(100%)&lt;BR /&gt;Female 15(100%) 13(100%)</description>
      <pubDate>Sun, 02 Apr 2023 17:36:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867649#M342688</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-02T17:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Table restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867652#M342691</link>
      <description>&lt;P&gt;I would like to point out that rarely do I think it is worthwhile to combine numbers and percents into one text string — like&amp;nbsp;15(100%) — as you have done. Even if you have an absolute unyielding requirement to make the output look like table B, working hard to generate table A is the &lt;A href="https://en.wikipedia.org/wiki/XY_problem" target="_self"&gt;xy problem&lt;/A&gt;, it gets you somewhere, but not in a direction that gets you easily to your final destination.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;One idea is to simply give up the fact that you want percents in parentheses in a text string, and do as I do, create a column in a table with the count and then the next column contains the percent. And if necessary you could simply try to talk people out of having number and percent in parentheses in a text string, and point out that this is the same information, but presented in an easier to read (and easier to create) format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If it is an absolute requirement that the table look exactly like Table B, you should still skip table A, go back to the raw data and use the &lt;A href="https://communities.sas.com/t5/forums/replypage/board-id/programming/message-id/342688" target="_self"&gt;%TABLEN macro&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Apr 2023 19:42:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867652#M342691</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-04-02T19:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Table restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867691#M342705</link>
      <description>&lt;P&gt;So A looks like it could be a dataset.&amp;nbsp; Perhaps something like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a;
  infile cards dsd dlm='|';
  input Gender :$7.  active :$20. placebo :$20.;
cards;
Male  |15(100%)|13(100%)
Female|15(100%)|13(100%)
;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But B does not look like a dataset.&amp;nbsp; What are the variable names?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do you want to generate a REPORT that looks like that? If so why not generate the report from the dataset you used to generate A and just skip dataset A.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 01:57:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867691#M342705</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-04-03T01:57:29Z</dc:date>
    </item>
    <item>
      <title>Re: Table restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867704#M342712</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;Thank you for your response.&lt;/DIV&gt;&lt;DIV&gt;Any idea of what I can do from the begining to arrive at B?&lt;/DIV&gt;&lt;P&gt;This is my code below and how I arrived at table A;&lt;/P&gt;&lt;DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;data dmed;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set dmx1_dmy1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;keep gender active;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;proc freq data=dmed;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;table gender active/ nopercent out=dm_freq;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;data cat_freq1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set dm_freq;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;length count 7 percent 6;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;male= catx("(", put(count, 2.), put(percent, 3.), "%)");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;female = catx("(",put(count, 2.), put(percent, 3.), "%)");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where active ne .;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;drop count percent;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;data dfrem;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set dmx1_dmy1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;keep gender placebo;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;proc freq data=dfrem;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;table gender placebo/ nopercent out=dm_freq2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;data cat_freq2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set dm_freq2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;length count 7 percent 6;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;male= catx("(", put(count, 2.), put(percent, 3.), "%)");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;female = catx("(",put(count, 2.), put(percent, 3.), "%)");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;where placebo ne .;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;drop count percent;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;data cat_freq1_freq2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set cat_freq1 cat_freq2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;proc sort data= cat_freq1_freq2 out=sorted_cat_freq;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;by active;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;proc transpose data= sorted_cat_freq out=transpose_freq;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;*by active;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;var male female;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;data my_freq(rename=(_name_=Gender COL1=placebo col2=active));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set transpose_freq;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;*drop active;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;proc sql;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;create table my_freq_rear as&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select gender, active, placebo&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from my_freq;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;quit;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;data Ade_lib.demog;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set my_freq_rear&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mymeans;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 07:15:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867704#M342712</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-03T07:15:31Z</dc:date>
    </item>
    <item>
      <title>Re: Table restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867714#M342720</link>
      <description>&lt;P&gt;Please post an example for dataset&amp;nbsp;&lt;SPAN&gt;dmx1_dmy1. Use a DATA step with DATALINES, so we can quickly recreate your dataset in our environment..&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 07:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867714#M342720</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2023-04-03T07:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Table restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867722#M342722</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dm;&lt;BR /&gt;input pat active $gender age placebo;&lt;BR /&gt;datalines;&lt;BR /&gt;101&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; Male&amp;nbsp; &amp;nbsp; &amp;nbsp; 37&amp;nbsp; &amp;nbsp;0&lt;BR /&gt;102&amp;nbsp; 1&amp;nbsp; &amp;nbsp; Female&amp;nbsp; 40&amp;nbsp; &amp;nbsp; .&lt;BR /&gt;103&amp;nbsp; 1&amp;nbsp; &amp;nbsp; Male&amp;nbsp; &amp;nbsp; &amp;nbsp; 50&amp;nbsp; &amp;nbsp; .&lt;BR /&gt;104&amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp;Female&amp;nbsp; 60&amp;nbsp; &amp;nbsp;0&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Gender was initially 1 and 2, I formated it to male and female.&lt;/P&gt;&lt;P&gt;dmx1_dmy1 appear like this;&lt;/P&gt;&lt;P&gt;Pat&amp;nbsp; &amp;nbsp; &amp;nbsp;Active&amp;nbsp; &amp;nbsp; Gender&amp;nbsp; &amp;nbsp; Age&amp;nbsp; &amp;nbsp; &amp;nbsp; Placebo&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Male&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;37&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Female&amp;nbsp; &amp;nbsp; 40&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Male&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;104&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Female&amp;nbsp; &amp;nbsp; 60&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 09:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867722#M342722</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-03T09:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: Table restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867723#M342723</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data dm;&lt;BR /&gt;input pat active $gender age placebo;&lt;BR /&gt;datalines;&lt;BR /&gt;101&amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; Male&amp;nbsp; &amp;nbsp; &amp;nbsp; 37&amp;nbsp; &amp;nbsp;0&lt;BR /&gt;102&amp;nbsp; 1&amp;nbsp; &amp;nbsp; Female&amp;nbsp; 40&amp;nbsp; &amp;nbsp; .&lt;BR /&gt;103&amp;nbsp; 1&amp;nbsp; &amp;nbsp; Male&amp;nbsp; &amp;nbsp; &amp;nbsp; 50&amp;nbsp; &amp;nbsp; .&lt;BR /&gt;104&amp;nbsp; .&amp;nbsp; &amp;nbsp; &amp;nbsp;Female&amp;nbsp; 60&amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;Gender was initially 1 and 2, I formated it to male and female.&lt;/P&gt;&lt;P&gt;dmx1_dmy1 appear like this;&lt;/P&gt;&lt;P&gt;Pat&amp;nbsp; &amp;nbsp; &amp;nbsp;Active&amp;nbsp; &amp;nbsp; Gender&amp;nbsp; &amp;nbsp; Age&amp;nbsp; &amp;nbsp; &amp;nbsp; Placebo&lt;/P&gt;&lt;P&gt;101&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Male&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;37&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;&lt;P&gt;102&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Female&amp;nbsp; &amp;nbsp; 40&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;103&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Male&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 50&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&lt;/P&gt;&lt;P&gt;104&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;.&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Female&amp;nbsp; &amp;nbsp; 60&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 09:12:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867723#M342723</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-03T09:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: Table restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867769#M342735</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;Looks like you need a report, not a dataset. As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;suggested above, you could skip all data steps and use Proc Report.&amp;nbsp;&lt;BR /&gt;Example;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data dm1;
set dm;
order=1;
run; 

proc report data=dm1 out=have(drop= order _:);
	column gender active placebo order;
	define gender/'' display;
	define active/display;
	define placebo/display;
	define order/order noprint;
	compute before order;
		line @1 text $20.;
		if order=1 then text= "Gender";
	endcomp;
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output&amp;nbsp;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="output.PNG" style="width: 184px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/82278iF5288A85B5A51F0B/image-size/large?v=v2&amp;amp;px=999" role="button" title="output.PNG" alt="output.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 14:22:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/867769#M342735</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2023-04-03T14:22:32Z</dc:date>
    </item>
    <item>
      <title>Re: Table restructuring</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/868356#M343025</link>
      <description>Thank you, sir. It is a class work, I will research the %tableN.&lt;BR /&gt;Thanks for your response.&lt;BR /&gt;</description>
      <pubDate>Wed, 05 Apr 2023 21:14:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Table-restructuring/m-p/868356#M343025</guid>
      <dc:creator>PrinceAde</dc:creator>
      <dc:date>2023-04-05T21:14:30Z</dc:date>
    </item>
  </channel>
</rss>

