<?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 ODS in Proc Surveyfreq question in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485760#M287146</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the output delivery system in proc surveyfreq to output a data set that contains my desired statistics: RowPercent, RowLowerCL, RowUpperCL. The following code works to give me some of what I want, but not everything and not in the desired layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="x_language-sas"&gt;proc surveyfreq data=data1;
cluster school;
strata class;
weight stwt;
table (gender gradeid youth [other vars]l)*(cursmk eversmk [other vars])/ cl row nocellpct nostd nofreq nowt nototal;
ods output CrossTabs=ResponseTable;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would appreciate any advice on the following questions:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Is there a way to suppress the "F_[var]" columns from appearing?&lt;/P&gt;&lt;P&gt;-Is there a way to get the variable columns to list, for example, "yes" and "no" instead of 0 and 1?&lt;/P&gt;&lt;P&gt;-Is there any way to shift the position of the columns so that the demographic variables can be listed together followed by the two response variable columns in the output data set (e.g., having the gender and gradeid column next to each other and the cursmk and eversmk columns next to each other) without having to manually perform this task in Excel?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;I have attached two screenshots that show the resulting data set I get when I run the above SAS code. Thank you for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="photo 1.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22379iFBBA3C312D43F355/image-size/large?v=v2&amp;amp;px=999" role="button" title="photo 1.jpg" alt="photo 1.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="photo 2 jpeg.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22380i5E2DAACA8BBD5229/image-size/large?v=v2&amp;amp;px=999" role="button" title="photo 2 jpeg.jpg" alt="photo 2 jpeg.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 10 Aug 2018 13:34:16 GMT</pubDate>
    <dc:creator>jag07g</dc:creator>
    <dc:date>2018-08-10T13:34:16Z</dc:date>
    <item>
      <title>ODS in Proc Surveyfreq question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485760#M287146</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am using the output delivery system in proc surveyfreq to output a data set that contains my desired statistics: RowPercent, RowLowerCL, RowUpperCL. The following code works to give me some of what I want, but not everything and not in the desired layout.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class="x_language-sas"&gt;proc surveyfreq data=data1;
cluster school;
strata class;
weight stwt;
table (gender gradeid youth [other vars]l)*(cursmk eversmk [other vars])/ cl row nocellpct nostd nofreq nowt nototal;
ods output CrossTabs=ResponseTable;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I would appreciate any advice on the following questions:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Is there a way to suppress the "F_[var]" columns from appearing?&lt;/P&gt;&lt;P&gt;-Is there a way to get the variable columns to list, for example, "yes" and "no" instead of 0 and 1?&lt;/P&gt;&lt;P&gt;-Is there any way to shift the position of the columns so that the demographic variables can be listed together followed by the two response variable columns in the output data set (e.g., having the gender and gradeid column next to each other and the cursmk and eversmk columns next to each other) without having to manually perform this task in Excel?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;I have attached two screenshots that show the resulting data set I get when I run the above SAS code. Thank you for your help.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="photo 1.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22379iFBBA3C312D43F355/image-size/large?v=v2&amp;amp;px=999" role="button" title="photo 1.jpg" alt="photo 1.jpg" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="photo 2 jpeg.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22380i5E2DAACA8BBD5229/image-size/large?v=v2&amp;amp;px=999" role="button" title="photo 2 jpeg.jpg" alt="photo 2 jpeg.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 13:34:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485760#M287146</guid>
      <dc:creator>jag07g</dc:creator>
      <dc:date>2018-08-10T13:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: ODS in Proc Surveyfreq question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485773#M287147</link>
      <description>&lt;P&gt;Just add a datastep after your code to do the additional formatting, maybe:&lt;/P&gt;
&lt;PRE&gt;data responsetable;&lt;BR /&gt;  retain /* put your column order required here */
  set responsetable (drop=f_:);&lt;BR /&gt;  /* Decode data here like&lt;BR /&gt;  ...=ifc(strip(...)="1","Male","Female");&lt;BR /&gt;  with the ... replaced by variable names */&lt;BR /&gt;run;
  &lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Aug 2018 13:59:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485773#M287147</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2018-08-10T13:59:02Z</dc:date>
    </item>
    <item>
      <title>Re: ODS in Proc Surveyfreq question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485784#M287148</link>
      <description>&lt;P&gt;Thank you--this solved my problem of column order and removing the formatted variable columns. I am still a little unsure&amp;nbsp;about the code to change 0,1 into labels.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For gender, I would like to list 0 for&amp;nbsp;"male"&amp;nbsp;and 1 for "female" and in other cases, like for cursmk, I would like 1 to&amp;nbsp;appear as&amp;nbsp;"yes" and 2 to appear as "no." Would the code look like this? Does any command come before listing the variable name. I am sorry I am not familiar with ifc and strip options. Thank you very much again.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;.....&lt;BR /&gt;set ResponseTable4 (drop=F_gender F_eversmk F_gradeid F_ethnicityid F_sportsid F_swatid F_youth F_schlvl F_cursmk);
gender=ifc(strip(gender))="0","Male","1","Female");
cursmk=ifc(strip(cursmk))="1", "Yes", "2", "No");&lt;BR /&gt;[other vars].......&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Aug 2018 14:31:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485784#M287148</guid>
      <dc:creator>jag07g</dc:creator>
      <dc:date>2018-08-10T14:31:42Z</dc:date>
    </item>
    <item>
      <title>Re: ODS in Proc Surveyfreq question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485793#M287149</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214271"&gt;@jag07g&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you--this solved my problem of column order and removing the formatted variable columns. I am still a little unsure&amp;nbsp;about the code to change 0,1 into labels.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For gender, I would like to list 0 for&amp;nbsp;"male"&amp;nbsp;and 1 for "female" and in other cases, like for cursmk, I would like 1 to&amp;nbsp;appear as&amp;nbsp;"yes" and 2 to appear as "no." Would the code look like this? Does any command come before listing the variable name. I am sorry I am not familiar with ifc and strip options. Thank you very much again.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;.....&lt;BR /&gt;set ResponseTable4 (drop=F_gender F_eversmk F_gradeid F_ethnicityid F_sportsid F_swatid F_youth F_schlvl F_cursmk);
gender=ifc(strip(gender))="0","Male","1","Female");
cursmk=ifc(strip(cursmk))="1", "Yes", "2", "No");&lt;BR /&gt;[other vars].......&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Formats are your friend.&lt;/P&gt;
&lt;P&gt;Proc format;&lt;/P&gt;
&lt;P&gt;value sex&lt;/P&gt;
&lt;P&gt;0='Male'&lt;/P&gt;
&lt;P&gt;1='Female'&lt;/P&gt;
&lt;P&gt;;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;It appears that your gender variable is actually numeric.&lt;/P&gt;
&lt;P&gt;Then when you want to see the Male/Female instead of 0/1 use the format. If you add:&lt;/P&gt;
&lt;P&gt;format gender sex. ;&lt;/P&gt;
&lt;P&gt;in the surveyfreq code the format will be assigned to the output and the default appearance as long as SAS can find your format (is active in the current session) it will display Male/Female by default.&lt;/P&gt;
&lt;P&gt;The format could be permanently assigned to your output set with proc datasets or in any report or further analysis step.&lt;/P&gt;
&lt;P&gt;The Yes/no format would be very similar.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 14:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485793#M287149</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-10T14:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: ODS in Proc Surveyfreq question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485822#M287150</link>
      <description>&lt;P&gt;Thank you. I was thinking proc format would work for this, but it is not outputting my value labels when I run surveyfreq.&amp;nbsp; Here is my code: Does proc format need to be listed in a different location?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname fyts17 'C:\User; 
data dataset_new;
set dataset_old; 
format _all_;

proc format;
value sex
0="Male"
1="Female"
;
run;

proc surveyfreq data=dataset_new;
weight stwt;
table (gender youth schlvl)*(eversmk cursmk)/ cl row nocellpct nostd nofreq nowt nototal;
format gender sex;
ods output CrossTabs=ResponseTable;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 10 Aug 2018 15:41:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485822#M287150</guid>
      <dc:creator>jag07g</dc:creator>
      <dc:date>2018-08-10T15:41:58Z</dc:date>
    </item>
    <item>
      <title>Re: ODS in Proc Surveyfreq question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485834#M287151</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/214271"&gt;@jag07g&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thank you. I was thinking proc format would work for this, but it is not outputting my value labels when I run surveyfreq.&amp;nbsp; Here is my code: Does proc format need to be listed in a different location?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname fyts17 'C:\User; 
data dataset_new;
set dataset_old; 
format _all_;

proc format;
value sex
0="Male"
1="Female"
;
run;

proc surveyfreq data=dataset_new;
weight stwt;
table (gender youth schlvl)*(eversmk cursmk)/ cl row nocellpct nostd nofreq nowt nototal;
format gender sex&lt;FONT color="#ff0000" size="5"&gt;.&lt;/FONT&gt;;
ods output CrossTabs=ResponseTable;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Format names have a dot at the end to indicate that they are formats and not variables, see the red dot above. For formats that display decimal values a digit after the dot indicates the number of decimals.&lt;/P&gt;
&lt;P&gt;You can also change the number of displayed characters by providing a digit: format gender sex1. ; would only display the M or F value. Which is why your custom format names cannot end in a digit.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 15:58:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485834#M287151</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-08-10T15:58:17Z</dc:date>
    </item>
    <item>
      <title>Re: ODS in Proc Surveyfreq question</title>
      <link>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485849#M287152</link>
      <description>Thanks so much! I was forgetting the dot.</description>
      <pubDate>Fri, 10 Aug 2018 16:31:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/ODS-in-Proc-Surveyfreq-question/m-p/485849#M287152</guid>
      <dc:creator>jag07g</dc:creator>
      <dc:date>2018-08-10T16:31:57Z</dc:date>
    </item>
  </channel>
</rss>

