I don't mean to be overly critical of Mary's contribution to this
thread, but I am troubled by parts of what she wrote.
First, let's review the role of ODS with SAS Procedures. PROCs
generate a series of Data Components, which are then passed to ODS, a
part of BASE SAS Software. ODS binds each Data Component to a Table
Template and a Style Template and then "delivers" the resulting
"table" or "object" to "destinations." The default destination is
LISTING, or your output window. So, I think it is incorrect so say
that we want "the portion of ODS that you want to save;" instead, we
want ODS to "deliver" our output to the OUTPUT destination, which
means we want to save some portion of the PROC-generated Data
Component as either a permanent or temporary SAS data set.
Second, specifying a valid permanent or temporary SAS data set name in
the ODS OUTPUT statement is "enough" to create the data set. There is
_zero_ need to "initialize a SAS data set to empty" at ANY point or
process in the SAS system, ever.. This is, to me, confusing and
unnecessary, as well as bad coding practice.
Third, there are a lot of limitations to saving PROC FREQ-generated
output as SAS data sets. If you use the OUT= option in the TABLES
statement to generate a SAS data set, and have specified two or more
variable names in the TABLES Statement, the the data set will only
contain frequency table info for the LAST variable you specified in
the statement. That is a well-known and documented limitation of the
procedure.
You can use ODS to have it deliver the contents of the OneWayFreqs
object/table to either a permanent or temporary SAS data set.
However, if you specify the NOPRINT option in your PROC FREQ step to
suprress printing on the tables in your output window, then the PROC's
ability to transfer Data Components to ODS is disabled. This is a
fundamental rule of using ODS with PROCS: using a NOPRINT option in
any PROC step prevents it from 'communicating' with the Output
Delivery System.
So, if you want the Data Component generated by PROC FREQ 'saved' as a
SAS data set, but don't want the output displayed in your Output
Window, you need to both OPEN the OUTPUT destination and close the
LISTING destination;
Form example;
ODS LISTING CLOSE;
ODS OUTPUT ONEWAYFREQS = MyFreqs;
PROC FREQ Data = My.Data;
TABLES var1 var2 var3
RUN;
ODS LISTING; * < re-open listing destination at end of PROC FREQ step;
You can then display your MyFreqs Data set using PROC PRINT or the
VIEWTABLE. I am not exactly in love with the structure/contents of
this table, but what you see is what you get.
I hope this helps and that Santa is good to all !
Regards,
Andrew Karp
Sierra Information Services
www.sierrainformation.com
Sonoma, CA USA
On Dec 23, 12:35 pm, mlhow...@avalon.net (Mary) wrote:
> You can save almost all output to a data step by using ODS.
> 1. Find out the name of the ODS output by adding the statement
> ods trace on;
> just before your proc freq.
> 2. Once you know the name of the portion of ODS that you want
> to save, use the ODS OUTPUT statement to save it:
> data onewayfreqs_set;
> stop; /* initialize to empty */
> run;
> ods output onewayfreqs=3Donewayfreqs_set;
> proc freq....
> -Mary
> ----- Original Message -----=20
> From: McKeehen, Gina M.=20
> To: SA...@LISTSERV.UGA.EDU=20
> Sent: Tuesday, December 23, 2008 1:29 PM
> Subject: Output the Results of a Proc Freq To A SAS Dataset
> Good day Everyone,
> If I want to make this an permanent output, to be saved as a separate
> file how would I do so?
> I have been trying for a few days and having no success. Don't know if =
> a
> proc printto or out=3D applies here
> Or maybe neither does. I do not want it in my log, just saved
> separately on its own.
> proc freq data=3Dout.abc ;
> by plan;
> table cnt
> h_cmc
> h_cmc*(clm_dx_1_cd clm_dx_2_cd )
> H_LDLC_SCRN*H_LDLC_LT100
> /list missing;
> title3 "ABC Sample";
> title4 "Sample Detail for 2006";
> run;
> Thanks,
> Gina M McKeehen
> CONFIDENTIALITY NOTICE: This E-Mail is intended only for the use of =
> the individual or entity to which it is addressed and may contain =
> information that is privileged, confidential and exempt from disclosure =
> under applicable law. If you have received this communication in error, =
> please do not distribute and delete the original message. Please notify =
> the sender by E-Mail at the address shown. Thank you for your compliance.- Hide quoted text -
> - Show quoted text -