<?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 PROC FREQ -- getting both unformatted and formatted values into CSV file in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29084#M4445</link>
    <description>We need to get one-way frequency output for several hundred variables into a single SAS data set, so that we can compare counts and percents across different years of data.&lt;BR /&gt;
&lt;BR /&gt;
I looked at the data set produced by the OneWayFreqs ODS output option. It provides both unformatted and formatted values (e.g. columns for Sex and F_Sex), but the data set is hard to work with for a large number of tables, since it has a separate pair of columns for each tabulated variable.&lt;BR /&gt;
&lt;BR /&gt;
It then occurred to me that it might be simpler to just route the PROC FREQ output to a CSV file, and it turns out that this output is much more compact and directly usable for my purposes. However, it only contains the formatted variable values, and it would be handy if I could get both formatted and unformatted.&lt;BR /&gt;
&lt;BR /&gt;
One would think this would be possible, but after spending some time looking at the template code and PROC TEMPLATE code, I sure can't figure out how.</description>
    <pubDate>Thu, 04 Nov 2010 20:31:01 GMT</pubDate>
    <dc:creator>MikeRhoads</dc:creator>
    <dc:date>2010-11-04T20:31:01Z</dc:date>
    <item>
      <title>PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29084#M4445</link>
      <description>We need to get one-way frequency output for several hundred variables into a single SAS data set, so that we can compare counts and percents across different years of data.&lt;BR /&gt;
&lt;BR /&gt;
I looked at the data set produced by the OneWayFreqs ODS output option. It provides both unformatted and formatted values (e.g. columns for Sex and F_Sex), but the data set is hard to work with for a large number of tables, since it has a separate pair of columns for each tabulated variable.&lt;BR /&gt;
&lt;BR /&gt;
It then occurred to me that it might be simpler to just route the PROC FREQ output to a CSV file, and it turns out that this output is much more compact and directly usable for my purposes. However, it only contains the formatted variable values, and it would be handy if I could get both formatted and unformatted.&lt;BR /&gt;
&lt;BR /&gt;
One would think this would be possible, but after spending some time looking at the template code and PROC TEMPLATE code, I sure can't figure out how.</description>
      <pubDate>Thu, 04 Nov 2010 20:31:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29084#M4445</guid>
      <dc:creator>MikeRhoads</dc:creator>
      <dc:date>2010-11-04T20:31:01Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29085#M4446</link>
      <description>Hi:&lt;BR /&gt;
  Are you using the format to "collapse" levels, like collapsing AGE=11 and AGE=12 into one category for frequency purposes or are you just formatting individual values??? Or are you just formatting character variables?? It's sort of hard to visualize what you are doing with formats and what you want from your description. What statistics do you want -- do you want the whole 9 yards (freq, percent, cum freq, cum percent as well as the formatted and unformatted variables)???&lt;BR /&gt;
     &lt;BR /&gt;
  I would expect that if you were using the format to collapse that it would be virtually impossible to get both the formatted and unformatted values out of PROC FREQ. Can you mock something up with one of the the SASHELP files and a couple of variables to illustrate what you're getting and what you want?&lt;BR /&gt;
 &lt;BR /&gt;
  The other issue that I see is that the define block for the Variable column is set to PRINT=OFF (because it inherits from Base.Freq.Variable which is set to PRINT=OFF) -- but when I turn PRINT=ON for the Variable column, I -DO- get the Variable and the FVariable columns in the CSV file, but they contain the same (formatted) values.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Thu, 04 Nov 2010 23:55:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29085#M4446</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-04T23:55:15Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29086#M4447</link>
      <description>Sometimes we collapse and sometimes we don't. For the ones where we just relabel without collapsing, the idea is to be able to see both the coded value in the data set, and the formatted value. When we collapse, it would be nice to have a "representative value" that we could use if necessary to get records back in the desired order, although there are ways we could work around that.&lt;BR /&gt;
&lt;BR /&gt;
Here's a sample:&lt;BR /&gt;
&lt;BR /&gt;
/* Do a little formatting on copy of sashelp.class for testing */&lt;BR /&gt;
	proc format;&lt;BR /&gt;
	value agef&lt;BR /&gt;
	  0-12   = 'Tween'&lt;BR /&gt;
	  13-19  = 'Teen'&lt;BR /&gt;
	;&lt;BR /&gt;
	value $sexf&lt;BR /&gt;
	  'M'     = 'Male'&lt;BR /&gt;
	  'F'     = 'Female'&lt;BR /&gt;
    ;&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
	data tempclass;&lt;BR /&gt;
	set   sashelp.class;&lt;BR /&gt;
	format  age agef.  sex $sexf.;&lt;BR /&gt;
	label&lt;BR /&gt;
	  age  = 'Age Group'&lt;BR /&gt;
	;&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
/* Close ODS LISTING, specify ODS output data set and CSV file */&lt;BR /&gt;
	ods listing close;&lt;BR /&gt;
	ods output  OneWayFreqs=MyProcFreqOutput;&lt;BR /&gt;
	filename csvout  temp;&lt;BR /&gt;
	ods csv  file=csvout;&lt;BR /&gt;
&lt;BR /&gt;
/* Run the tables */&lt;BR /&gt;
	proc freq  data=tempclass;&lt;BR /&gt;
	tables _all_ / missing;&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
/* Close output destinations and reopen LISTING destination */&lt;BR /&gt;
	ods output close;&lt;BR /&gt;
	ods csv close;&lt;BR /&gt;
	ods listing;</description>
      <pubDate>Fri, 05 Nov 2010 13:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29086#M4447</guid>
      <dc:creator>MikeRhoads</dc:creator>
      <dc:date>2010-11-05T13:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29087#M4448</link>
      <description>I'm not sure what you want as final output.  I think you want to "normalize" the OneWayFreqs table.  This does it in a way that I might want.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
data maybe;&lt;BR /&gt;
   length Variable $32 Vtype $1 _i_ nValue 8 cValue $50 Formatted $100;&lt;BR /&gt;
&lt;BR /&gt;
   if 0 then set MyProcFreqOutput;&lt;BR /&gt;
   array _c _character_;&lt;BR /&gt;
   array _n _numeric_;&lt;BR /&gt;
&lt;BR /&gt;
   if _n_ eq 1 then do;&lt;BR /&gt;
      declare hash vr();&lt;BR /&gt;
      vr.definekey('Variable','Vtype');&lt;BR /&gt;
      vr.definedata('Variable','Vtype','_i_');&lt;BR /&gt;
      vr.definedone();&lt;BR /&gt;
      do _i_ = 1 to dim(_c);&lt;BR /&gt;
         Variable = vname(_c[_i_]);&lt;BR /&gt;
         Vtype = vtype(_c[_i_]);&lt;BR /&gt;
         rc = vr.add();&lt;BR /&gt;
         end; &lt;BR /&gt;
      do _i_ = 1 to dim(_n);&lt;BR /&gt;
         Variable = vname(_n[_i_]);&lt;BR /&gt;
         Vtype = vtype(_n[_i_]);&lt;BR /&gt;
         rc = vr.add();&lt;BR /&gt;
         end;&lt;BR /&gt;
      rc = vr.output(dataset:'vr'); *not needed;&lt;BR /&gt;
      end;&lt;BR /&gt;
   set MyProcFreqOutput;&lt;BR /&gt;
   length nValue 8 cValue $50 Formatted $100;&lt;BR /&gt;
   Variable = scan(table,-1,' ');&lt;BR /&gt;
   Vtype = vtypeX(Variable);&lt;BR /&gt;
   formatted = vvalueX(Variable);&lt;BR /&gt;
   rc = vr.find();&lt;BR /&gt;
   select(Vtype);&lt;BR /&gt;
      when('N') nValue = _n[_i_];&lt;BR /&gt;
      when('C') cValue = _c[_i_];&lt;BR /&gt;
      end;&lt;BR /&gt;
   keep Variable Vtype nvalue cvalue formatted Freq: Perc: Cum:;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print data=vr;&lt;BR /&gt;
   run;&lt;BR /&gt;
proc print data=maybethis;&lt;BR /&gt;
   run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
Output&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
                                     n                                                            Cum         Cum&lt;BR /&gt;
       Obs    Variable    Vtype    Value    cValue      Formatted      Frequency    Percent    Frequency    Percent&lt;BR /&gt;
&lt;BR /&gt;
         1     Name         C         .     Alfred     Alfred                 1       5.26            1       5.26&lt;BR /&gt;
         2     Name         C         .     Alice      Alice                  1       5.26            2      10.53&lt;BR /&gt;
         3     Name         C         .     Barbara    Barbara                1       5.26            3      15.79&lt;BR /&gt;
         4     Name         C         .     Carol      Carol                  1       5.26            4      21.05&lt;BR /&gt;
         5     Name         C         .     Henry      Henry                  1       5.26            5      26.32&lt;BR /&gt;
         6     Name         C         .     James      James                  1       5.26            6      31.58&lt;BR /&gt;
         7     Name         C         .     Jane       Jane                   1       5.26            7      36.84&lt;BR /&gt;
         8     Name         C         .     Janet      Janet                  1       5.26            8      42.11&lt;BR /&gt;
         9     Name         C         .     Jeffrey    Jeffrey                1       5.26            9      47.37&lt;BR /&gt;
        10     Name         C         .     John       John                   1       5.26           10      52.63&lt;BR /&gt;
        11     Name         C         .     Joyce      Joyce                  1       5.26           11      57.89&lt;BR /&gt;
        12     Name         C         .     Judy       Judy                   1       5.26           12      63.16&lt;BR /&gt;
        13     Name         C         .     Louise     Louise                 1       5.26           13      68.42&lt;BR /&gt;
        14     Name         C         .     Mary       Mary                   1       5.26           14      73.68&lt;BR /&gt;
        15     Name         C         .     Philip     Philip                 1       5.26           15      78.95&lt;BR /&gt;
        16     Name         C         .     Robert     Robert                 1       5.26           16      84.21&lt;BR /&gt;
        17     Name         C         .     Ronald     Ronald                 1       5.26           17      89.47&lt;BR /&gt;
        18     Name         C         .     Thomas     Thomas                 1       5.26           18      94.74&lt;BR /&gt;
        19     Name         C         .     William    William                1       5.26           19     100.00&lt;BR /&gt;
        20     Sex          C         .     F          Female                 9      47.37            9      47.37&lt;BR /&gt;
        21     Sex          C         .     M          Male                  10      52.63           19     100.00&lt;BR /&gt;
        22     Age          N       11.0               Tween                  7      36.84            7      36.84&lt;BR /&gt;
        23     Age          N       13.0               Teen                  12      63.16           19     100.00&lt;BR /&gt;
        24     Height       N       51.3                       51.3           1       5.26            1       5.26&lt;BR /&gt;
        25     Height       N       56.3                       56.3           1       5.26            2      10.53&lt;BR /&gt;
        26     Height       N       56.5                       56.5           1       5.26            3      15.79&lt;BR /&gt;
        27     Height       N       57.3                       57.3           1       5.26            4      21.05&lt;BR /&gt;
        28     Height       N       57.5                       57.5           1       5.26            5      26.32&lt;BR /&gt;
        29     Height       N       59.0                         59           1       5.26            6      31.58&lt;BR /&gt;
        30     Height       N       59.8                       59.8           1       5.26            7      36.84&lt;BR /&gt;
        31     Height       N       62.5                       62.5           2      10.53            9      47.37&lt;BR /&gt;
        32     Height       N       62.8                       62.8           1       5.26           10      52.63&lt;BR /&gt;
        33     Height       N       63.5                       63.5           1       5.26           11      57.89&lt;BR /&gt;
        34     Height       N       64.3                       64.3           1       5.26           12      63.16&lt;BR /&gt;
        35     Height       N       64.8                       64.8           1       5.26           13      68.42&lt;BR /&gt;
        36     Height       N       65.3                       65.3           1       5.26           14      73.68&lt;BR /&gt;
        37     Height       N       66.5                       66.5           2      10.53           16      84.21&lt;BR /&gt;
        38     Height       N       67.0                         67           1       5.26           17      89.47&lt;BR /&gt;
        39     Height       N       69.0                         69           1       5.26           18      94.74&lt;BR /&gt;
        40     Height       N       72.0                         72           1       5.26           19     100.00&lt;BR /&gt;
        41     Weight       N       50.5                       50.5           1       5.26            1       5.26&lt;BR /&gt;
        42     Weight       N       77.0                         77           1       5.26            2      10.53&lt;BR /&gt;
        43     Weight       N       83.0                         83           1       5.26            3      15.79&lt;BR /&gt;
        44     Weight       N       84.0                         84           2      10.53            5      26.32&lt;BR /&gt;
        45     Weight       N       84.5                       84.5           1       5.26            6      31.58&lt;BR /&gt;
        46     Weight       N       85.0                         85           1       5.26            7      36.84&lt;BR /&gt;
        47     Weight       N       90.0                         90           1       5.26            8      42.11&lt;BR /&gt;
        48     Weight       N       98.0                         98           1       5.26            9      47.37&lt;BR /&gt;
        49     Weight       N       99.5                       99.5           1       5.26           10      52.63&lt;BR /&gt;
        50     Weight       N      102.5                      102.5           2      10.53           12      63.16&lt;BR /&gt;
        51     Weight       N      112.0                        112           2      10.53           14      73.68&lt;BR /&gt;
        52     Weight       N      112.5                      112.5           2      10.53           16      84.21&lt;BR /&gt;
        53     Weight       N      128.0                        128           1       5.26           17      89.47&lt;BR /&gt;
        54     Weight       N      133.0                        133           1       5.26           18      94.74&lt;BR /&gt;
        55     Weight       N      150.0                        150           1       5.26           19     100.00&lt;BR /&gt;
[/pre]</description>
      <pubDate>Fri, 05 Nov 2010 18:53:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29087#M4448</guid>
      <dc:creator>data_null__</dc:creator>
      <dc:date>2010-11-05T18:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29088#M4449</link>
      <description>Yep -- that's pretty much exactly what I'm looking for.  Thanks!&lt;BR /&gt;
&lt;BR /&gt;
I still can't quite understand why both the unformatted and formatted values are available in the output data set, but I can't get both directly in the other destinations.</description>
      <pubDate>Fri, 05 Nov 2010 20:35:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29088#M4449</guid>
      <dc:creator>MikeRhoads</dc:creator>
      <dc:date>2010-11-05T20:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29089#M4450</link>
      <description>Mike:&lt;BR /&gt;
&lt;BR /&gt;
  When I create an ouput dataset from this code:&lt;BR /&gt;
[pre]&lt;BR /&gt;
ods listing;&lt;BR /&gt;
proc format;&lt;BR /&gt;
  value agef 0-12 = 'tween'&lt;BR /&gt;
        13-high = 'teen';&lt;BR /&gt;
run;&lt;BR /&gt;
                                                  &lt;BR /&gt;
ods output onewayfreqs=work.testF;&lt;BR /&gt;
proc freq data=sashelp.class;&lt;BR /&gt;
  tables age height;&lt;BR /&gt;
  format height 8.0 age agef.;&lt;BR /&gt;
run;&lt;BR /&gt;
                      &lt;BR /&gt;
proc print data=work.testF noobs;&lt;BR /&gt;
run;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
  I see that the FORMATTED value is used for F_Variable and for Variable, even in the output dataset.  Note how F_Age and Age are BOTH the formatted values and that F_Height and Height are BOTH using the format.&lt;BR /&gt;
[pre]&lt;BR /&gt;
                                                             Cum         Cum&lt;BR /&gt;
   Table        F_Age     Age     Frequency    Percent    Frequency    Percent    F_Height      Height&lt;BR /&gt;
&lt;BR /&gt;
Table Age       tween    tween           7      36.84            7      36.84                        .&lt;BR /&gt;
Table Age       teen     teen           12      63.16           19     100.00                        .&lt;BR /&gt;
Table Height                 .           1       5.26            1       5.26        51             51&lt;BR /&gt;
Table Height                 .           1       5.26            2      10.53        56             56&lt;BR /&gt;
Table Height                 .           2      10.53            4      21.05        57             57&lt;BR /&gt;
Table Height                 .           1       5.26            5      26.32        58             58&lt;BR /&gt;
Table Height                 .           1       5.26            6      31.58        59             59&lt;BR /&gt;
Table Height                 .           1       5.26            7      36.84        60             60&lt;BR /&gt;
Table Height                 .           3      15.79           10      52.63        63             63&lt;BR /&gt;
Table Height                 .           2      10.53           12      63.16        64             64&lt;BR /&gt;
Table Height                 .           2      10.53           14      73.68        65             65&lt;BR /&gt;
Table Height                 .           3      15.79           17      89.47        67             67&lt;BR /&gt;
Table Height                 .           1       5.26           18      94.74        69             69&lt;BR /&gt;
Table Height                 .           1       5.26           19     100.00        72             72&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
So in my mind, it's a moot point whether you can reveal both Variable and F_Variable in the destination. I &lt;U&gt;can&lt;/U&gt; change the TABLE template so that you can see both Variable and F_Variable in your ODS output.&lt;BR /&gt;
&lt;BR /&gt;
But all you're going to see is the formatted value if you use the changed table template. Is that what you want???? I can send you the template-- but it's not going to produce anything close to the solution posted by data_null_.&lt;BR /&gt;
&lt;BR /&gt;
As for WHY you can get the 2 columns with ODS OUTPUT and not otherwise without changing the table template ... I suspect, but don't know for sure that the PROC FREQ procedure writer had one of those "Surely, NOBODY would ever want to see both F_Variable and Variable in printed output" moments.&lt;BR /&gt;
&lt;BR /&gt;
cynthia</description>
      <pubDate>Sat, 06 Nov 2010 16:37:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29089#M4450</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-06T16:37:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29090#M4451</link>
      <description>Cynthia,&lt;BR /&gt;
&lt;BR /&gt;
With the output data set, the "unformatted" variables (such as Age) actually contain the unformatted values, but with the formats associated with them. You can get the unformatted values simply by removing the format.&lt;BR /&gt;
&lt;BR /&gt;
I did mess around with the template a bit, getting both columns into my CSV file, but with the formatted values for each. I had a certain amount of success with the following:&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
/* Try modifying the table template */&lt;BR /&gt;
    proc template;                                                                &lt;BR /&gt;
      edit  Base.Freq.OneWayList;                                          &lt;BR /&gt;
        define Variable;                                                        &lt;BR /&gt;
          parent = Base.Freq.Variable; &lt;BR /&gt;
          print  = ON;&lt;BR /&gt;
          format = best.; &lt;BR /&gt;
        end;  &lt;BR /&gt;
    end;                                                                       &lt;BR /&gt;
run;    &lt;BR /&gt;
	&lt;BR /&gt;
/* Do a little formatting on copy of sashelp.class for testing */&lt;BR /&gt;
	proc format;&lt;BR /&gt;
	value agef&lt;BR /&gt;
	  0-12   = 'Tween'&lt;BR /&gt;
	  13-19  = 'Teen'&lt;BR /&gt;
	;&lt;BR /&gt;
	value $sexf&lt;BR /&gt;
	  'M'     = 'Male'&lt;BR /&gt;
	  'F'     = 'Female'&lt;BR /&gt;
    ;&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
	data tempclass;&lt;BR /&gt;
	set   sashelp.class;&lt;BR /&gt;
	format  age agef.  sex $sexf.;&lt;BR /&gt;
	label&lt;BR /&gt;
	  age  = 'Age Group'&lt;BR /&gt;
	;&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
/* Close ODS LISTING, specify ODS tagset */&lt;BR /&gt;
	ods listing close;&lt;BR /&gt;
	filename csvout  temp;&lt;BR /&gt;
	ods csv  file=csvout;&lt;BR /&gt;
&lt;BR /&gt;
/* Run the tables */&lt;BR /&gt;
	proc freq  data=tempclass;&lt;BR /&gt;
	tables _numeric_ / missing;&lt;BR /&gt;
	run;&lt;BR /&gt;
&lt;BR /&gt;
/* Close output destinations and reopen LISTING destination */&lt;BR /&gt;
	ods csv  close;&lt;BR /&gt;
	ods listing;&lt;BR /&gt;
[/pre]&lt;BR /&gt;
&lt;BR /&gt;
This gives me both unformatted and formatted in my CSV. But it only works if I'm only running frequencies for numeric variables. If I include character variables in my TABLES statement, I (not surprisingly) get a message from SAS -- WARNING: Wrong type of format for data type: best.&lt;BR /&gt;
&lt;BR /&gt;
Now, if there were only a way to specify one format if the underlying column was numeric and a different one for character values ...   &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;</description>
      <pubDate>Sun, 07 Nov 2010 16:04:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29090#M4451</guid>
      <dc:creator>MikeRhoads</dc:creator>
      <dc:date>2010-11-07T16:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29091#M4452</link>
      <description>Hi:&lt;BR /&gt;
  Try FORMAT=_UNDEF_; in your template code. It gets around the issue of character variables. But then it doesn't seem to treat numeric variables the way your solution treats them. If you could live with creating the output dataset and then displaying the output dataset to ODS CSV, that might be an alternate solution.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia&lt;BR /&gt;
&lt;BR /&gt;
[pre]&lt;BR /&gt;
/* Try modifying the table template */&lt;BR /&gt;
ods path work.tmp(update) sasuser.templat(update)&lt;BR /&gt;
         sashelp.tmplmst(read);&lt;BR /&gt;
                                         &lt;BR /&gt;
    proc template;                                                                &lt;BR /&gt;
      edit  Base.Freq.OneWayList;                                          &lt;BR /&gt;
        define Variable;                                                        &lt;BR /&gt;
          parent = Base.Freq.Variable; &lt;BR /&gt;
          print  = ON;&lt;BR /&gt;
          format = _UNDEF_; &lt;BR /&gt;
        end;  &lt;BR /&gt;
    end;                                                                       &lt;BR /&gt;
run;   	                       &lt;BR /&gt;
[/pre]</description>
      <pubDate>Mon, 08 Nov 2010 16:18:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29091#M4452</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-08T16:18:39Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29092#M4453</link>
      <description>Yes -- so close and yet so far. _UNDEF_ obviously does "something" -- works great with character variables, and it obviously does something with previously unformatted numerics (the "unformatted" value is now truly numeric). But it still doesn't get rid of the user-written format.&lt;BR /&gt;
&lt;BR /&gt;
Oh well. At least we have an alternative ...   &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Wed, 10 Nov 2010 20:53:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29092#M4453</guid>
      <dc:creator>MikeRhoads</dc:creator>
      <dc:date>2010-11-10T20:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: PROC FREQ -- getting both unformatted and formatted values into CSV file</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29093#M4454</link>
      <description>Well, you could have 1 template for numeric variables (with BEST) in one item store and then a diff template for character variables (with _UNDEF_) and use a targeted ODS PATH statement to control which template was going to be used ... it would mean 2 proc freqs with an ODS PATH between them.&lt;BR /&gt;
 &lt;BR /&gt;
cynthia</description>
      <pubDate>Wed, 10 Nov 2010 21:34:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/PROC-FREQ-getting-both-unformatted-and-formatted-values-into-CSV/m-p/29093#M4454</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2010-11-10T21:34:00Z</dc:date>
    </item>
  </channel>
</rss>

