<?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: Creating a table from PROC SURVEYFREQ in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-from-PROC-SURVEYFREQ/m-p/927948#M41665</link>
    <description>&lt;P&gt;You use ODS OUTPUT to create data sets containing the results shown in the results.&lt;/P&gt;
&lt;P&gt;Then you manipulate the data set for custom reports and use another report procedure like Proc Print, Report or Tabulate to show the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The bit that you need is to know the name of the object(s) created by your code. That is accomplished by placing ODS Trace statements around the procedure:&lt;/P&gt;
&lt;PRE&gt;ODS Trace on;

&amp;lt;procedure creating output&amp;gt;

ods trace off;&lt;/PRE&gt;
&lt;P&gt;The Log will show something like:&lt;/P&gt;
&lt;PRE&gt;Output Added:
-------------
Name:       Summary
Label:      Data Summary
Template:   Stat.SurveyFreq.Summary
Path:       Surveyfreq.Summary
-------------

Output Added:
-------------
Name:       CrossTabs
Label:      CrossTabulation Table
Template:   Stat.SurveyFreq.CrossTabFreqs
Path:       Surveyfreq.Table1.CrossTabs
-------------


&lt;/PRE&gt;
&lt;P&gt;The piece you need is the NAME. These generally appear in the order of the results.&lt;/P&gt;
&lt;P&gt;So once you know the name of the object(s) you want then you add them to ODS output in the proc code such as:&lt;/P&gt;
&lt;PRE&gt;Proc surveyfreq data=work.ocd;
   table dsm_OCD*(Contamination_OC Harming_OC Ordering_OC Hoarding_OC         
           Sex_rel_mor_OC Any_OC One_OC Two_OC Three_OC Four_OC   
           Five_OC)/nowt;
    weight finalp2wt;
   ods output crosstabs=mydataset;
run;&lt;/PRE&gt;
&lt;P&gt;This creates a data set name Mydataset with all of the crosstab results. If you have tests they would have results in different objects.&lt;/P&gt;
&lt;P&gt;Since I don't have your data&amp;nbsp; I can't see what you might mean by "both variables have a value of 1".&lt;/P&gt;
&lt;P&gt;The output data set will have a variable TABLE that has the variables used to create the given observation.&amp;nbsp; The values of the Variables will be there plus another variable named F_&amp;lt;your variable&amp;gt; that contains the formatted value of the variable in text. The variable Frequency has the N value, Percent the % and StdErr.&lt;/P&gt;
&lt;P&gt;Note that the total values appear so check the Formatted value of the variable for the word Total to identify such.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 May 2024 20:14:22 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2024-05-10T20:14:22Z</dc:date>
    <item>
      <title>Creating a table from PROC SURVEYFREQ</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-from-PROC-SURVEYFREQ/m-p/927914#M41664</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm trying to create a table like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 496px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96418i689D081E6AEE029E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From this output:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot_10-5-2024_135831_odamid-apse1.oda.sas.com.jpeg" style="width: 134px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/96419i853702795B514283/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot_10-5-2024_135831_odamid-apse1.oda.sas.com.jpeg" alt="Screenshot_10-5-2024_135831_odamid-apse1.oda.sas.com.jpeg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only want to keep the values where both variable have a value of 1.&lt;/P&gt;&lt;P&gt;The above output was created using the following code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;Proc surveyfreq data=work.ocd;
table dsm_OCD*(Contamination_OC Harming_OC Ordering_OC Hoarding_OC Sex_rel_mor_OC Any_OC One_OC Two_OC Three_OC Four_OC Five_OC)/nowt;
weight finalp2wt;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 May 2024 18:03:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-from-PROC-SURVEYFREQ/m-p/927914#M41664</guid>
      <dc:creator>talaln</dc:creator>
      <dc:date>2024-05-10T18:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table from PROC SURVEYFREQ</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-from-PROC-SURVEYFREQ/m-p/927948#M41665</link>
      <description>&lt;P&gt;You use ODS OUTPUT to create data sets containing the results shown in the results.&lt;/P&gt;
&lt;P&gt;Then you manipulate the data set for custom reports and use another report procedure like Proc Print, Report or Tabulate to show the results.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The bit that you need is to know the name of the object(s) created by your code. That is accomplished by placing ODS Trace statements around the procedure:&lt;/P&gt;
&lt;PRE&gt;ODS Trace on;

&amp;lt;procedure creating output&amp;gt;

ods trace off;&lt;/PRE&gt;
&lt;P&gt;The Log will show something like:&lt;/P&gt;
&lt;PRE&gt;Output Added:
-------------
Name:       Summary
Label:      Data Summary
Template:   Stat.SurveyFreq.Summary
Path:       Surveyfreq.Summary
-------------

Output Added:
-------------
Name:       CrossTabs
Label:      CrossTabulation Table
Template:   Stat.SurveyFreq.CrossTabFreqs
Path:       Surveyfreq.Table1.CrossTabs
-------------


&lt;/PRE&gt;
&lt;P&gt;The piece you need is the NAME. These generally appear in the order of the results.&lt;/P&gt;
&lt;P&gt;So once you know the name of the object(s) you want then you add them to ODS output in the proc code such as:&lt;/P&gt;
&lt;PRE&gt;Proc surveyfreq data=work.ocd;
   table dsm_OCD*(Contamination_OC Harming_OC Ordering_OC Hoarding_OC         
           Sex_rel_mor_OC Any_OC One_OC Two_OC Three_OC Four_OC   
           Five_OC)/nowt;
    weight finalp2wt;
   ods output crosstabs=mydataset;
run;&lt;/PRE&gt;
&lt;P&gt;This creates a data set name Mydataset with all of the crosstab results. If you have tests they would have results in different objects.&lt;/P&gt;
&lt;P&gt;Since I don't have your data&amp;nbsp; I can't see what you might mean by "both variables have a value of 1".&lt;/P&gt;
&lt;P&gt;The output data set will have a variable TABLE that has the variables used to create the given observation.&amp;nbsp; The values of the Variables will be there plus another variable named F_&amp;lt;your variable&amp;gt; that contains the formatted value of the variable in text. The variable Frequency has the N value, Percent the % and StdErr.&lt;/P&gt;
&lt;P&gt;Note that the total values appear so check the Formatted value of the variable for the word Total to identify such.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2024 20:14:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Creating-a-table-from-PROC-SURVEYFREQ/m-p/927948#M41665</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-05-10T20:14:22Z</dc:date>
    </item>
  </channel>
</rss>

