<?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: Extracting data from the result window and export as formatted tables in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972958#M377611</link>
    <description>&lt;P&gt;Thank You!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works perfectly for 1 variable dataset.&lt;/P&gt;&lt;P&gt;(I've succeeded in adding also the column with Variable name - that for me is a great achievement!&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried with one of my datasets with lots of variables but I obtain only one raw with some statistics that actually I do not not where they come from..... seems some sort of sums ... I cannot explain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as proc freq is concerned, would You mind to provide me with a datastep that puts results in one row? adding also a p-value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tks in advance&lt;/P&gt;</description>
    <pubDate>Wed, 20 Aug 2025 09:16:17 GMT</pubDate>
    <dc:creator>antor82</dc:creator>
    <dc:date>2025-08-20T09:16:17Z</dc:date>
    <item>
      <title>Extracting data from the result window and export as formatted tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972948#M377606</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I use to copy every single data from a result output into word tables for scientific publications, but this is actually time consuming.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wonder if there is a faster procedure.&lt;/P&gt;&lt;P&gt;I attach a sample datastep for your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;data graze;
   length GrazeType $ 10;
   input GrazeType $ WtGain @@;
   datalines;
controlled  45   controlled  62
controlled  96   controlled 128
controlled 120   controlled  99
controlled  28   controlled  50
controlled 109   controlled 115
controlled  39   controlled  96
controlled  87   controlled 100
controlled  76   controlled  80
continuous  94   continuous  12
continuous  26   continuous  89
continuous  88   continuous  96
continuous  85   continuous 130
continuous  75   continuous  54
continuous 112   continuous  69
continuous 104   continuous  95
continuous  53   continuous  21
;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;then perform ttest&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc ttest data=graze;
   class GrazeType;
   var WtGain;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and obtain this results&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-08-20 at 09.23.31.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109128i94793CF2C31AC7F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-08-20 at 09.23.31.png" alt="Screenshot 2025-08-20 at 09.23.31.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2025-08-20 at 09.23.47.png" style="width: 688px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109129iC5CAD2DE98B15ED5/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2025-08-20 at 09.23.47.png" alt="Screenshot 2025-08-20 at 09.23.47.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here I come to my point:&lt;/P&gt;&lt;P&gt;is there a way to automatically obtain the following output from the above results?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Variables&lt;/TD&gt;&lt;TD&gt;Group1&lt;/TD&gt;&lt;TD&gt;Group2&lt;/TD&gt;&lt;TD&gt;p-value&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;WtGain&lt;/TD&gt;&lt;TD&gt;75.2+/-33.8&lt;/TD&gt;&lt;TD&gt;83.1+/-30.5&lt;/TD&gt;&lt;TD&gt;0.49&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Similarly for proc freq, obviously as count (%)&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2025 07:40:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972948#M377606</guid>
      <dc:creator>antor82</dc:creator>
      <dc:date>2025-08-20T07:40:30Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data from the result window and export as formatted tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972952#M377608</link>
      <description>I would start with storing the output in data sets, which can be obtained by using ODS:&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/statug/15.2/statug_ttest_details38.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/statug/15.2/statug_ttest_details38.htm&lt;/A&gt;&lt;BR /&gt;Then exactly how to get them into Word is a different issue, and again ODS can be of help.&lt;BR /&gt;Are you in a single user environment, otr do you by chance have Add-in for MSOffice and/or access to a SAS Stored Process server?</description>
      <pubDate>Wed, 20 Aug 2025 08:21:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972952#M377608</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2025-08-20T08:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data from the result window and export as formatted tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972953#M377609</link>
      <description>&lt;P&gt;I use SAS on demand for academics.&lt;/P&gt;&lt;P&gt;Never heard of&amp;nbsp;&lt;SPAN&gt;Add-in for MSOffice! this sounds nice!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2025 08:40:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972953#M377609</guid>
      <dc:creator>antor82</dc:creator>
      <dc:date>2025-08-20T08:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data from the result window and export as formatted tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972954#M377610</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/178542"&gt;@antor82&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is how you can extract the desired statistics from ODS output datasets as mentioned by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;:&lt;/P&gt;
&lt;PRE&gt;ods output conflimits=cl ttests=tt equality=ev;
&lt;FONT color="#999999"&gt;proc ttest data=graze;
  class GrazeType;
  var WtGain;
run;&lt;/FONT&gt;

data want(keep=&lt;STRONG&gt;Variable&lt;/STRONG&gt; Gr: p_:);
set cl(obs=2) ev tt end=last;
array Group[2] $15;
if _n_&amp;lt;=2 then group[_n_]=catx('±',round(mean,0.1),round(stddev,0.1));
else if _n_=3 then pf=probf;
else if Variances='Equal' then pte=probt;
else ptu=probt;
if last;
p_value=ifn(pf&amp;gt;0.05,pte,ptu);
format p_value pvalue6.2;
retain Gr: p:;
run;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;Variable     Group1       Group2      p_value

 WtGain     75.2±33.8    83.1±30.5     0.49&lt;/PRE&gt;
&lt;P&gt;[EDIT: Added &lt;FONT face="courier new,courier"&gt;Variable&lt;/FONT&gt;&amp;nbsp;in the KEEP= dataset option to include it in the result.]&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Similarly for PROC FREQ, where the OUT= dataset is sufficient:&lt;/P&gt;
&lt;PRE&gt;&lt;FONT color="#999999"&gt;proc freq data=graze;
tables grazetype &lt;FONT color="#000000"&gt;/ out=frq;&lt;/FONT&gt;
run;&lt;/FONT&gt;

data want2(keep=GrazeType cntpct);
set frq;
length cntpct $12;
cntpct=put(count,4.)||' ('||put(percent,4.1)||')';
label cntpct='Count (%)';
run;&lt;/PRE&gt;
&lt;P&gt;Result:&lt;/P&gt;
&lt;PRE&gt;GrazeType     Count (%)

continuous    16 (50.0)
controlled    16 (50.0)&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2025 09:30:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972954#M377610</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-08-20T09:30:36Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data from the result window and export as formatted tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972958#M377611</link>
      <description>&lt;P&gt;Thank You!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works perfectly for 1 variable dataset.&lt;/P&gt;&lt;P&gt;(I've succeeded in adding also the column with Variable name - that for me is a great achievement!&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried with one of my datasets with lots of variables but I obtain only one raw with some statistics that actually I do not not where they come from..... seems some sort of sums ... I cannot explain.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as proc freq is concerned, would You mind to provide me with a datastep that puts results in one row? adding also a p-value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Tks in advance&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2025 09:16:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972958#M377611</guid>
      <dc:creator>antor82</dc:creator>
      <dc:date>2025-08-20T09:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting data from the result window and export as formatted tables</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972960#M377612</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/178542"&gt;@antor82&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I've tried with one of my datasets with lots of variables ...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Can you post an example of such a dataset (e.g., with two or three variables) and what type of output you want to get from that?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/178542"&gt;@antor82&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;As far as proc freq is concerned, would You mind to provide me with a datastep that puts results in one row? adding also a p-value?&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;How many categories are there and what hypothesis (e.g. "equal proportions") do you want to test?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Aug 2025 09:39:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Extracting-data-from-the-result-window-and-export-as-formatted/m-p/972960#M377612</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2025-08-20T09:39:25Z</dc:date>
    </item>
  </channel>
</rss>

